<!DOCTYPE html>
<!-- saved from url=(0075)https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript -->
<html class="dark" lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style type="text/css">.turbolinks-progress-bar {
  position: fixed;
  display: block;
  top: 0;
  left: 0;
  height: 3px;
  background: #0076ff;
  z-index: 9999;
  transition: width 300ms ease-out, opacity 150ms 150ms ease-in;
  transform: translate3d(0, 0, 0);
}</style><style type="text/css">.swal-icon--error{border-color:#f27474;-webkit-animation:animateErrorIcon .5s;animation:animateErrorIcon .5s}.swal-icon--error__x-mark{position:relative;display:block;-webkit-animation:animateXMark .5s;animation:animateXMark .5s}.swal-icon--error__line{position:absolute;height:5px;width:47px;background-color:#f27474;display:block;top:37px;border-radius:2px}.swal-icon--error__line--left{-webkit-transform:rotate(45deg);transform:rotate(45deg);left:17px}.swal-icon--error__line--right{-webkit-transform:rotate(-45deg);transform:rotate(-45deg);right:16px}@-webkit-keyframes animateErrorIcon{0%{-webkit-transform:rotateX(100deg);transform:rotateX(100deg);opacity:0}to{-webkit-transform:rotateX(0deg);transform:rotateX(0deg);opacity:1}}@keyframes animateErrorIcon{0%{-webkit-transform:rotateX(100deg);transform:rotateX(100deg);opacity:0}to{-webkit-transform:rotateX(0deg);transform:rotateX(0deg);opacity:1}}@-webkit-keyframes animateXMark{0%{-webkit-transform:scale(.4);transform:scale(.4);margin-top:26px;opacity:0}50%{-webkit-transform:scale(.4);transform:scale(.4);margin-top:26px;opacity:0}80%{-webkit-transform:scale(1.15);transform:scale(1.15);margin-top:-6px}to{-webkit-transform:scale(1);transform:scale(1);margin-top:0;opacity:1}}@keyframes animateXMark{0%{-webkit-transform:scale(.4);transform:scale(.4);margin-top:26px;opacity:0}50%{-webkit-transform:scale(.4);transform:scale(.4);margin-top:26px;opacity:0}80%{-webkit-transform:scale(1.15);transform:scale(1.15);margin-top:-6px}to{-webkit-transform:scale(1);transform:scale(1);margin-top:0;opacity:1}}.swal-icon--warning{border-color:#f8bb86;-webkit-animation:pulseWarning .75s infinite alternate;animation:pulseWarning .75s infinite alternate}.swal-icon--warning__body{width:5px;height:47px;top:10px;border-radius:2px;margin-left:-2px}.swal-icon--warning__body,.swal-icon--warning__dot{position:absolute;left:50%;background-color:#f8bb86}.swal-icon--warning__dot{width:7px;height:7px;border-radius:50%;margin-left:-4px;bottom:-11px}@-webkit-keyframes pulseWarning{0%{border-color:#f8d486}to{border-color:#f8bb86}}@keyframes pulseWarning{0%{border-color:#f8d486}to{border-color:#f8bb86}}.swal-icon--success{border-color:#a5dc86}.swal-icon--success:after,.swal-icon--success:before{content:"";border-radius:50%;position:absolute;width:60px;height:120px;background:#fff;-webkit-transform:rotate(45deg);transform:rotate(45deg)}.swal-icon--success:before{border-radius:120px 0 0 120px;top:-7px;left:-33px;-webkit-transform:rotate(-45deg);transform:rotate(-45deg);-webkit-transform-origin:60px 60px;transform-origin:60px 60px}.swal-icon--success:after{border-radius:0 120px 120px 0;top:-11px;left:30px;-webkit-transform:rotate(-45deg);transform:rotate(-45deg);-webkit-transform-origin:0 60px;transform-origin:0 60px;-webkit-animation:rotatePlaceholder 4.25s ease-in;animation:rotatePlaceholder 4.25s ease-in}.swal-icon--success__ring{width:80px;height:80px;border:4px solid hsla(98,55%,69%,.2);border-radius:50%;box-sizing:content-box;position:absolute;left:-4px;top:-4px;z-index:2}.swal-icon--success__hide-corners{width:5px;height:90px;background-color:#fff;padding:1px;position:absolute;left:28px;top:8px;z-index:1;-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}.swal-icon--success__line{height:5px;background-color:#a5dc86;display:block;border-radius:2px;position:absolute;z-index:2}.swal-icon--success__line--tip{width:25px;left:14px;top:46px;-webkit-transform:rotate(45deg);transform:rotate(45deg);-webkit-animation:animateSuccessTip .75s;animation:animateSuccessTip .75s}.swal-icon--success__line--long{width:47px;right:8px;top:38px;-webkit-transform:rotate(-45deg);transform:rotate(-45deg);-webkit-animation:animateSuccessLong .75s;animation:animateSuccessLong .75s}@-webkit-keyframes rotatePlaceholder{0%{-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}5%{-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}12%{-webkit-transform:rotate(-405deg);transform:rotate(-405deg)}to{-webkit-transform:rotate(-405deg);transform:rotate(-405deg)}}@keyframes rotatePlaceholder{0%{-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}5%{-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}12%{-webkit-transform:rotate(-405deg);transform:rotate(-405deg)}to{-webkit-transform:rotate(-405deg);transform:rotate(-405deg)}}@-webkit-keyframes animateSuccessTip{0%{width:0;left:1px;top:19px}54%{width:0;left:1px;top:19px}70%{width:50px;left:-8px;top:37px}84%{width:17px;left:21px;top:48px}to{width:25px;left:14px;top:45px}}@keyframes animateSuccessTip{0%{width:0;left:1px;top:19px}54%{width:0;left:1px;top:19px}70%{width:50px;left:-8px;top:37px}84%{width:17px;left:21px;top:48px}to{width:25px;left:14px;top:45px}}@-webkit-keyframes animateSuccessLong{0%{width:0;right:46px;top:54px}65%{width:0;right:46px;top:54px}84%{width:55px;right:0;top:35px}to{width:47px;right:8px;top:38px}}@keyframes animateSuccessLong{0%{width:0;right:46px;top:54px}65%{width:0;right:46px;top:54px}84%{width:55px;right:0;top:35px}to{width:47px;right:8px;top:38px}}.swal-icon--info{border-color:#c9dae1}.swal-icon--info:before{width:5px;height:29px;bottom:17px;border-radius:2px;margin-left:-2px}.swal-icon--info:after,.swal-icon--info:before{content:"";position:absolute;left:50%;background-color:#c9dae1}.swal-icon--info:after{width:7px;height:7px;border-radius:50%;margin-left:-3px;top:19px}.swal-icon{width:80px;height:80px;border-width:4px;border-style:solid;border-radius:50%;padding:0;position:relative;box-sizing:content-box;margin:20px auto}.swal-icon:first-child{margin-top:32px}.swal-icon--custom{width:auto;height:auto;max-width:100%;border:none;border-radius:0}.swal-icon img{max-width:100%;max-height:100%}.swal-title{color:rgba(0,0,0,.65);font-weight:600;text-transform:none;position:relative;display:block;padding:13px 16px;font-size:27px;line-height:normal;text-align:center;margin-bottom:0}.swal-title:first-child{margin-top:26px}.swal-title:not(:first-child){padding-bottom:0}.swal-title:not(:last-child){margin-bottom:13px}.swal-text{font-size:16px;position:relative;float:none;line-height:normal;vertical-align:top;text-align:left;display:inline-block;margin:0;padding:0 10px;font-weight:400;color:rgba(0,0,0,.64);max-width:calc(100% - 20px);overflow-wrap:break-word;box-sizing:border-box}.swal-text:first-child{margin-top:45px}.swal-text:last-child{margin-bottom:45px}.swal-footer{text-align:right;padding-top:13px;margin-top:13px;padding:13px 16px;border-radius:inherit;border-top-left-radius:0;border-top-right-radius:0}.swal-button-container{margin:5px;display:inline-block;position:relative}.swal-button{background-color:#7cd1f9;color:#fff;border:none;box-shadow:none;border-radius:5px;font-weight:600;font-size:14px;padding:10px 24px;margin:0;cursor:pointer}.swal-button:not([disabled]):hover{background-color:#78cbf2}.swal-button:active{background-color:#70bce0}.swal-button:focus{outline:none;box-shadow:0 0 0 1px #fff,0 0 0 3px rgba(43,114,165,.29)}.swal-button[disabled]{opacity:.5;cursor:default}.swal-button::-moz-focus-inner{border:0}.swal-button--cancel{color:#555;background-color:#efefef}.swal-button--cancel:not([disabled]):hover{background-color:#e8e8e8}.swal-button--cancel:active{background-color:#d7d7d7}.swal-button--cancel:focus{box-shadow:0 0 0 1px #fff,0 0 0 3px rgba(116,136,150,.29)}.swal-button--danger{background-color:#e64942}.swal-button--danger:not([disabled]):hover{background-color:#df4740}.swal-button--danger:active{background-color:#cf423b}.swal-button--danger:focus{box-shadow:0 0 0 1px #fff,0 0 0 3px rgba(165,43,43,.29)}.swal-content{padding:0 20px;margin-top:20px;font-size:medium}.swal-content:last-child{margin-bottom:20px}.swal-content__input,.swal-content__textarea{-webkit-appearance:none;background-color:#fff;border:none;font-size:14px;display:block;box-sizing:border-box;width:100%;border:1px solid rgba(0,0,0,.14);padding:10px 13px;border-radius:2px;transition:border-color .2s}.swal-content__input:focus,.swal-content__textarea:focus{outline:none;border-color:#6db8ff}.swal-content__textarea{resize:vertical}.swal-button--loading{color:transparent}.swal-button--loading~.swal-button__loader{opacity:1}.swal-button__loader{position:absolute;height:auto;width:43px;z-index:2;left:50%;top:50%;-webkit-transform:translateX(-50%) translateY(-50%);transform:translateX(-50%) translateY(-50%);text-align:center;pointer-events:none;opacity:0}.swal-button__loader div{display:inline-block;float:none;vertical-align:baseline;width:9px;height:9px;padding:0;border:none;margin:2px;opacity:.4;border-radius:7px;background-color:hsla(0,0%,100%,.9);transition:background .2s;-webkit-animation:swal-loading-anim 1s infinite;animation:swal-loading-anim 1s infinite}.swal-button__loader div:nth-child(3n+2){-webkit-animation-delay:.15s;animation-delay:.15s}.swal-button__loader div:nth-child(3n+3){-webkit-animation-delay:.3s;animation-delay:.3s}@-webkit-keyframes swal-loading-anim{0%{opacity:.4}20%{opacity:.4}50%{opacity:1}to{opacity:.4}}@keyframes swal-loading-anim{0%{opacity:.4}20%{opacity:.4}50%{opacity:1}to{opacity:.4}}.swal-overlay{position:fixed;top:0;bottom:0;left:0;right:0;text-align:center;font-size:0;overflow-y:auto;background-color:rgba(0,0,0,.4);z-index:10000;pointer-events:none;opacity:0;transition:opacity .3s}.swal-overlay:before{content:" ";display:inline-block;vertical-align:middle;height:100%}.swal-overlay--show-modal{opacity:1;pointer-events:auto}.swal-overlay--show-modal .swal-modal{opacity:1;pointer-events:auto;box-sizing:border-box;-webkit-animation:showSweetAlert .3s;animation:showSweetAlert .3s;will-change:transform}.swal-modal{width:478px;opacity:0;pointer-events:none;background-color:#fff;text-align:center;border-radius:5px;position:static;margin:20px auto;display:inline-block;vertical-align:middle;-webkit-transform:scale(1);transform:scale(1);-webkit-transform-origin:50% 50%;transform-origin:50% 50%;z-index:10001;transition:opacity .2s,-webkit-transform .3s;transition:transform .3s,opacity .2s;transition:transform .3s,opacity .2s,-webkit-transform .3s}@media (max-width:500px){.swal-modal{width:calc(100% - 20px)}}@-webkit-keyframes showSweetAlert{0%{-webkit-transform:scale(1);transform:scale(1)}1%{-webkit-transform:scale(.5);transform:scale(.5)}45%{-webkit-transform:scale(1.05);transform:scale(1.05)}80%{-webkit-transform:scale(.95);transform:scale(.95)}to{-webkit-transform:scale(1);transform:scale(1)}}@keyframes showSweetAlert{0%{-webkit-transform:scale(1);transform:scale(1)}1%{-webkit-transform:scale(.5);transform:scale(.5)}45%{-webkit-transform:scale(1.05);transform:scale(1.05)}80%{-webkit-transform:scale(.95);transform:scale(.95)}to{-webkit-transform:scale(1);transform:scale(1)}}</style>
<script type="text/javascript" src="./First non-repeating character Solutions _ Codewars_files/364dba19a3"></script><script src="./First non-repeating character Solutions _ Codewars_files/nr-1214.min.js.下载"></script><script type="text/javascript">window.NREUM||(NREUM={});NREUM.info={"beacon":"bam.nr-data.net","errorBeacon":"bam.nr-data.net","licenseKey":"364dba19a3","applicationID":"15446117","transactionName":"Jg5ZQEdYXQ1XRRZWXQEEaFddVl0NV1leUEFKEVtVTA==","queueTime":0,"applicationTime":413,"agent":""}</script>
<script type="text/javascript">(window.NREUM||(NREUM={})).init={ajax:{deny_list:["bam.nr-data.net"]}};(window.NREUM||(NREUM={})).loader_config={licenseKey:"364dba19a3",applicationID:"15446117"};window.NREUM||(NREUM={}),__nr_require=function(t,e,n){function r(n){if(!e[n]){var i=e[n]={exports:{}};t[n][0].call(i.exports,function(e){var i=t[n][1][e];return r(i||e)},i,i.exports)}return e[n].exports}if("function"==typeof __nr_require)return __nr_require;for(var i=0;i<n.length;i++)r(n[i]);return r}({1:[function(t,e,n){function r(){}function i(t,e,n,r){return function(){return s.recordSupportability("API/"+e+"/called"),o(t+e,[u.now()].concat(c(arguments)),n?null:this,r),n?void 0:this}}var o=t("handle"),a=t(10),c=t(11),f=t("ee").get("tracer"),u=t("loader"),s=t(4),d=NREUM;"undefined"==typeof window.newrelic&&(newrelic=d);var p=["setPageViewName","setCustomAttribute","setErrorHandler","finished","addToTrace","inlineHit","addRelease"],l="api-",v=l+"ixn-";a(p,function(t,e){d[e]=i(l,e,!0,"api")}),d.addPageAction=i(l,"addPageAction",!0),d.setCurrentRouteName=i(l,"routeName",!0),e.exports=newrelic,d.interaction=function(){return(new r).get()};var m=r.prototype={createTracer:function(t,e){var n={},r=this,i="function"==typeof e;return o(v+"tracer",[u.now(),t,n],r),function(){if(f.emit((i?"":"no-")+"fn-start",[u.now(),r,i],n),i)try{return e.apply(this,arguments)}catch(t){throw f.emit("fn-err",[arguments,this,t],n),t}finally{f.emit("fn-end",[u.now()],n)}}}};a("actionText,setName,setAttribute,save,ignore,onEnd,getContext,end,get".split(","),function(t,e){m[e]=i(v,e)}),newrelic.noticeError=function(t,e){"string"==typeof t&&(t=new Error(t)),s.recordSupportability("API/noticeError/called"),o("err",[t,u.now(),!1,e])}},{}],2:[function(t,e,n){function r(t){if(NREUM.init){for(var e=NREUM.init,n=t.split("."),r=0;r<n.length-1;r++)if(e=e[n[r]],"object"!=typeof e)return;return e=e[n[n.length-1]]}}e.exports={getConfiguration:r}},{}],3:[function(t,e,n){var r=!1;try{var i=Object.defineProperty({},"passive",{get:function(){r=!0}});window.addEventListener("testPassive",null,i),window.removeEventListener("testPassive",null,i)}catch(o){}e.exports=function(t){return r?{passive:!0,capture:!!t}:!!t}},{}],4:[function(t,e,n){function r(t,e){var n=[a,t,{name:t},e];return o("storeMetric",n,null,"api"),n}function i(t,e){var n=[c,t,{name:t},e];return o("storeEventMetrics",n,null,"api"),n}var o=t("handle"),a="sm",c="cm";e.exports={constants:{SUPPORTABILITY_METRIC:a,CUSTOM_METRIC:c},recordSupportability:r,recordCustom:i}},{}],5:[function(t,e,n){function r(){return c.exists&&performance.now?Math.round(performance.now()):(o=Math.max((new Date).getTime(),o))-a}function i(){return o}var o=(new Date).getTime(),a=o,c=t(12);e.exports=r,e.exports.offset=a,e.exports.getLastTimestamp=i},{}],6:[function(t,e,n){function r(t){return!(!t||!t.protocol||"file:"===t.protocol)}e.exports=r},{}],7:[function(t,e,n){function r(t,e){var n=t.getEntries();n.forEach(function(t){"first-paint"===t.name?l("timing",["fp",Math.floor(t.startTime)]):"first-contentful-paint"===t.name&&l("timing",["fcp",Math.floor(t.startTime)])})}function i(t,e){var n=t.getEntries();if(n.length>0){var r=n[n.length-1];if(u&&u<r.startTime)return;var i=[r],o=a({});o&&i.push(o),l("lcp",i)}}function o(t){t.getEntries().forEach(function(t){t.hadRecentInput||l("cls",[t])})}function a(t){var e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;if(e)return e.type&&(t["net-type"]=e.type),e.effectiveType&&(t["net-etype"]=e.effectiveType),e.rtt&&(t["net-rtt"]=e.rtt),e.downlink&&(t["net-dlink"]=e.downlink),t}function c(t){if(t instanceof y&&!w){var e=Math.round(t.timeStamp),n={type:t.type};a(n),e<=v.now()?n.fid=v.now()-e:e>v.offset&&e<=Date.now()?(e-=v.offset,n.fid=v.now()-e):e=v.now(),w=!0,l("timing",["fi",e,n])}}function f(t){"hidden"===t&&(u=v.now(),l("pageHide",[u]))}if(!("init"in NREUM&&"page_view_timing"in NREUM.init&&"enabled"in NREUM.init.page_view_timing&&NREUM.init.page_view_timing.enabled===!1)){var u,s,d,p,l=t("handle"),v=t("loader"),m=t(9),g=t(3),y=NREUM.o.EV;if("PerformanceObserver"in window&&"function"==typeof window.PerformanceObserver){s=new PerformanceObserver(r);try{s.observe({entryTypes:["paint"]})}catch(h){}d=new PerformanceObserver(i);try{d.observe({entryTypes:["largest-contentful-paint"]})}catch(h){}p=new PerformanceObserver(o);try{p.observe({type:"layout-shift",buffered:!0})}catch(h){}}if("addEventListener"in document){var w=!1,b=["click","keydown","mousedown","pointerdown","touchstart"];b.forEach(function(t){document.addEventListener(t,c,g(!1))})}m(f)}},{}],8:[function(t,e,n){function r(t,e){if(!i)return!1;if(t!==i)return!1;if(!e)return!0;if(!o)return!1;for(var n=o.split("."),r=e.split("."),a=0;a<r.length;a++)if(r[a]!==n[a])return!1;return!0}var i=null,o=null,a=/Version\/(\S+)\s+Safari/;if(navigator.userAgent){var c=navigator.userAgent,f=c.match(a);f&&c.indexOf("Chrome")===-1&&c.indexOf("Chromium")===-1&&(i="Safari",o=f[1])}e.exports={agent:i,version:o,match:r}},{}],9:[function(t,e,n){function r(t){function e(){t(c&&document[c]?document[c]:document[o]?"hidden":"visible")}"addEventListener"in document&&a&&document.addEventListener(a,e,i(!1))}var i=t(3);e.exports=r;var o,a,c;"undefined"!=typeof document.hidden?(o="hidden",a="visibilitychange",c="visibilityState"):"undefined"!=typeof document.msHidden?(o="msHidden",a="msvisibilitychange"):"undefined"!=typeof document.webkitHidden&&(o="webkitHidden",a="webkitvisibilitychange",c="webkitVisibilityState")},{}],10:[function(t,e,n){function r(t,e){var n=[],r="",o=0;for(r in t)i.call(t,r)&&(n[o]=e(r,t[r]),o+=1);return n}var i=Object.prototype.hasOwnProperty;e.exports=r},{}],11:[function(t,e,n){function r(t,e,n){e||(e=0),"undefined"==typeof n&&(n=t?t.length:0);for(var r=-1,i=n-e||0,o=Array(i<0?0:i);++r<i;)o[r]=t[e+r];return o}e.exports=r},{}],12:[function(t,e,n){e.exports={exists:"undefined"!=typeof window.performance&&window.performance.timing&&"undefined"!=typeof window.performance.timing.navigationStart}},{}],ee:[function(t,e,n){function r(){}function i(t){function e(t){return t&&t instanceof r?t:t?u(t,f,a):a()}function n(n,r,i,o,a){if(a!==!1&&(a=!0),!l.aborted||o){t&&a&&t(n,r,i);for(var c=e(i),f=m(n),u=f.length,s=0;s<u;s++)f[s].apply(c,r);var p=d[w[n]];return p&&p.push([b,n,r,c]),c}}function o(t,e){h[t]=m(t).concat(e)}function v(t,e){var n=h[t];if(n)for(var r=0;r<n.length;r++)n[r]===e&&n.splice(r,1)}function m(t){return h[t]||[]}function g(t){return p[t]=p[t]||i(n)}function y(t,e){l.aborted||s(t,function(t,n){e=e||"feature",w[n]=e,e in d||(d[e]=[])})}var h={},w={},b={on:o,addEventListener:o,removeEventListener:v,emit:n,get:g,listeners:m,context:e,buffer:y,abort:c,aborted:!1};return b}function o(t){return u(t,f,a)}function a(){return new r}function c(){(d.api||d.feature)&&(l.aborted=!0,d=l.backlog={})}var f="nr@context",u=t("gos"),s=t(10),d={},p={},l=e.exports=i();e.exports.getOrSetContext=o,l.backlog=d},{}],gos:[function(t,e,n){function r(t,e,n){if(i.call(t,e))return t[e];var r=n();if(Object.defineProperty&&Object.keys)try{return Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!1}),r}catch(o){}return t[e]=r,r}var i=Object.prototype.hasOwnProperty;e.exports=r},{}],handle:[function(t,e,n){function r(t,e,n,r){i.buffer([t],r),i.emit(t,e,n)}var i=t("ee").get("handle");e.exports=r,r.ee=i},{}],id:[function(t,e,n){function r(t){var e=typeof t;return!t||"object"!==e&&"function"!==e?-1:t===window?0:a(t,o,function(){return i++})}var i=1,o="nr@id",a=t("gos");e.exports=r},{}],loader:[function(t,e,n){function r(){if(!P++){var t=M.info=NREUM.info,e=g.getElementsByTagName("script")[0];if(setTimeout(u.abort,3e4),!(t&&t.licenseKey&&t.applicationID&&e))return u.abort();f(O,function(e,n){t[e]||(t[e]=n)});var n=a();c("mark",["onload",n+M.offset],null,"api"),c("timing",["load",n]);var r=g.createElement("script");0===t.agent.indexOf("http://")||0===t.agent.indexOf("https://")?r.src=t.agent:r.src=v+"://"+t.agent,e.parentNode.insertBefore(r,e)}}function i(){"complete"===g.readyState&&o()}function o(){c("mark",["domContent",a()+M.offset],null,"api")}var a=t(5),c=t("handle"),f=t(10),u=t("ee"),s=t(8),d=t(6),p=t(2),l=t(3),v=p.getConfiguration("ssl")===!1?"http":"https",m=window,g=m.document,y="addEventListener",h="attachEvent",w=m.XMLHttpRequest,b=w&&w.prototype,E=!d(m.location);NREUM.o={ST:setTimeout,SI:m.setImmediate,CT:clearTimeout,XHR:w,REQ:m.Request,EV:m.Event,PR:m.Promise,MO:m.MutationObserver};var x=""+location,O={beacon:"bam.nr-data.net",errorBeacon:"bam.nr-data.net",agent:"js-agent.newrelic.com/nr-1214.min.js"},T=w&&b&&b[y]&&!/CriOS/.test(navigator.userAgent),M=e.exports={offset:a.getLastTimestamp(),now:a,origin:x,features:{},xhrWrappable:T,userAgent:s,disabled:E};if(!E){t(1),t(7),g[y]?(g[y]("DOMContentLoaded",o,l(!1)),m[y]("load",r,l(!1))):(g[h]("onreadystatechange",i),m[h]("onload",r)),c("mark",["firstbyte",a.getLastTimestamp()],null,"api");var P=0}},{}],"wrap-function":[function(t,e,n){function r(t,e){function n(e,n,r,f,u){function nrWrapper(){var o,a,s,p;try{a=this,o=d(arguments),s="function"==typeof r?r(o,a):r||{}}catch(l){i([l,"",[o,a,f],s],t)}c(n+"start",[o,a,f],s,u);try{return p=e.apply(a,o)}catch(v){throw c(n+"err",[o,a,v],s,u),v}finally{c(n+"end",[o,a,p],s,u)}}return a(e)?e:(n||(n=""),nrWrapper[p]=e,o(e,nrWrapper,t),nrWrapper)}function r(t,e,r,i,o){r||(r="");var c,f,u,s="-"===r.charAt(0);for(u=0;u<e.length;u++)f=e[u],c=t[f],a(c)||(t[f]=n(c,s?f+r:r,i,f,o))}function c(n,r,o,a){if(!v||e){var c=v;v=!0;try{t.emit(n,r,o,e,a)}catch(f){i([f,n,r,o],t)}v=c}}return t||(t=s),n.inPlace=r,n.flag=p,n}function i(t,e){e||(e=s);try{e.emit("internal-error",t)}catch(n){}}function o(t,e,n){if(Object.defineProperty&&Object.keys)try{var r=Object.keys(t);return r.forEach(function(n){Object.defineProperty(e,n,{get:function(){return t[n]},set:function(e){return t[n]=e,e}})}),e}catch(o){i([o],n)}for(var a in t)l.call(t,a)&&(e[a]=t[a]);return e}function a(t){return!(t&&t instanceof Function&&t.apply&&!t[p])}function c(t,e){var n=e(t);return n[p]=t,o(t,n,s),n}function f(t,e,n){var r=t[e];t[e]=c(r,n)}function u(){for(var t=arguments.length,e=new Array(t),n=0;n<t;++n)e[n]=arguments[n];return e}var s=t("ee"),d=t(11),p="nr@original",l=Object.prototype.hasOwnProperty,v=!1;e.exports=r,e.exports.wrapFunction=c,e.exports.wrapInPlace=f,e.exports.argsToArray=u},{}]},{},["loader"]);</script>
<link href="./First non-repeating character Solutions _ Codewars_files/css" media="screen" rel="stylesheet"><link crossorigin="anonymous" href="./First non-repeating character Solutions _ Codewars_files/katex.min.css" integrity="sha384-MlJdn/WNKDGXveldHDdyRP1R4CTHr3FeuDNfhsLPYrq2t0UBkUdK2jyTnXPEK1NQ" rel="stylesheet"><link rel="stylesheet" media="screen" href="./First non-repeating character Solutions _ Codewars_files/application.f0d27ab4.css" data-turbolinks-track="reload"><script src="./First non-repeating character Solutions _ Codewars_files/application.51ba6ba3.js.下载" crossorigin="anonymous" type="module" defer="defer" data-turbolinks-track="reload"></script><link rel="modulepreload" href="https://www.codewars.com/packs/assets/vendor.3dfe9815.js" as="script" crossorigin="anonymous" defer="defer" data-turbolinks-track="reload"><link rel="stylesheet" media="screen" href="./First non-repeating character Solutions _ Codewars_files/application.cafe16e0.css" crossorigin="anonymous" defer="defer" data-turbolinks-track="reload"><script async="" src="./First non-repeating character Solutions _ Codewars_files/js"></script><script>window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());</script><script type="text/javascript">window.NREUM||(NREUM={});NREUM.info={"beacon":"bam.nr-data.net","errorBeacon":"bam.nr-data.net","licenseKey":"364dba19a3","applicationID":"15446117","transactionName":"Jg5ZQEdYXQ1XRRZWXQEEaFddVl0NV1leUEFKElhYQENYDlxE","queueTime":0,"applicationTime":1098,"agent":""}</script><title>First non-repeating character Solutions | Codewars</title><meta name="csrf-param" content="authenticity_token"><meta name="csrf-token" content="k+eQrXM74Xv66bxUiYhOpc+Y/ElxvMXyoF7qGOTqJcjhxbEe0PtbjtNb1+bVOBGZT/zsDZuPmjCrZWl54UE0Ww=="><meta content="width=device-width, initial-scale=1.0, maximum-scale=5.0" name="viewport"><meta content="First non-repeating character" property="og:title"><meta content="website" property="og:type"><meta content="Codewars" property="og:site_name"><meta content="https://www.codewars.com" property="og:url"><meta content="https://www.codewars.com/packs/assets/logo-square-paper-bg.c3d2b1eb.jpg" property="og:image"><meta content="https://www.codewars.com/packs/assets/logo-square-paper-bg.c3d2b1eb.jpg" property="og:image:secure_url"><meta content="Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential." property="og:description"><meta content="652826666" property="fb:admins"><meta content="110951985735625" property="fb:app_id"><meta content="@codewars" name="twitter:site"><meta content="Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential." name="description"><meta content="codewars, code kata, kata, code gym, coding, code practice, ruby, javascript, coffeescript, web development, software development, dojo" name="keywords"><meta content="EMv3k6eCCUuSkbwJpGlLbtsBd_lCvmvDp1Ucsv0rIvM" name="google-site-verification"></head><body class="solutions_view  full-viewport  logged-in" id="code_challenges"><div id="app"><h1 class="page-title">Kata</h1><div class="w-full" id="shell"><div class="sidenav-nubbin block md:hidden"><i class="icon-moon-list "></i></div><nav id="sidenav"><ul class="top"><li class="leading-relaxed nav-home"><a class="inline-flex items-center" href="https://www.codewars.com/dashboard"><div class="logo mt-3 flex-shrink-0"><img class="w-full h-full" src="./First non-repeating character Solutions _ Codewars_files/logo.61192cf7.svg"></div><span class="mt-10px ml-2.5">Dashboard</span></a></li><li class="leading-relaxed"><a class="inline-flex items-center" href="https://www.codewars.com/kata/latest/my-languages"><div class="my-0.5"><svg class="ml-1.5 w-6 h-6 inline-block" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path></svg></div><span class="ml-4">Kata</span></a></li><li class="leading-relaxed"><a class="inline-flex items-center" href="https://docs.codewars.com/" rel="noopener" target="_blank" title="The Codewars Docs"><div class="my-0.5"><svg class="ml-1.5 w-6 h-6 inline-block" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path></svg></div><span class="ml-4">Docs</span></a></li><li class="leading-relaxed"><a class="inline-flex items-center" href="https://blog.codewars.com/" rel="noopener" target="_blank" title="The Codewars Blog"><div class="my-0.5"><svg class="ml-1.5 w-6 h-6 inline-block" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path d="M6 5c7.18 0 13 5.82 13 13M6 11a7 7 0 017 7m-6 0a1 1 0 11-2 0 1 1 0 012 0z" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path></svg></div><span class="ml-4">Blog</span></a></li><li class="leading-relaxed"><a class="inline-flex items-center" href="https://www.codewars.com/kumite"><div class="my-0.5"><svg class="ml-1.5 w-6 h-6 inline-block" fill="none" height="24" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none" stroke="none"></path><path d="M4 12v-3a3 3 0 0 1 3 -3h13m-3 -3l3 3l-3 3"></path><path d="M20 12v3a3 3 0 0 1 -3 3h-13m3 3l-3 -3l3 -3"></path></svg></div><span class="ml-4">Kumite</span></a></li><li class="leading-relaxed"><a class="inline-flex items-center" href="https://www.codewars.com/topics"><div class="my-0.5"><svg class="ml-1.5 w-6 h-6 inline-block" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path d="M17 8h2a2 2 0 012 2v6a2 2 0 01-2 2h-2v4l-4-4H9a1.994 1.994 0 01-1.414-.586m0 0L11 14h4a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2v4l.586-.586z" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path></svg></div><span class="ml-4">Forum</span></a></li></ul><ul class="bottom"><li class="leading-relaxed nav-leaders"><a class="inline-flex items-center" href="https://www.codewars.com/users/leaderboard" title="Leaders"><div class="my-0.5"><svg class="ml-1.5 w-6 h-6 inline-block" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path></svg></div><span class="ml-4">Leaders</span></a></li></ul></nav><header class="main is-visible" id="main_header"><ul class="items"><li class="item-list"><a class="js-toggle-dark-mode w-6"><svg class="block dark:hidden" fill="currentColor" viewBox="0 0 20 20"><path clip-rule="evenodd" d="M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z" fill-rule="evenodd"></path></svg><svg class="hidden dark:block" fill="currentColor" viewBox="0 0 20 20"><path d="M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z"></path></svg></a></li><li class="item-list stars-item has-menu static"><a><i class="icon-moon-bookmark text-2xl"></i></a><div class="menu has-auto-scrolling right-0 shadow-lg"><div class="menu-body" style="max-height: 720px;"><ul class="divide-y space-y"><li><a><div>You have not starred any kata</div><div>To add some, just click the<span class="is-link ml-5px"><i class="icon-moon-star-empty is-small"></i></span>next to any kata title.</div></a></li></ul></div></div></li><li class="notifications-item has-menu static" id="notifications_drawer"><a><i class="icon-moon-bell text-2xl"></i></a><div class="menu right-0 shadow-lg"><div class="menu-body" style="max-height: 720px;"><div class="notifications-body"><ul class="divide-y"><li class="notification"><figure><img title="zowietao" data-tippy-content="zowietao" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></figure><figcaption><a data-notification-ids="61eac977567ca00001e59e0e" href="https://www.codewars.com/users/61d7ec1260d73c0040c8f066">100+ Honor: You now have the ability to weigh in on the ranking of beta kata!</a><div class="ml-15px"></div><time-ago datetime="2022-01-21T14:55:51.958+0000" lang="en" title="2022年1月21日 GMT+8 下午10:55">5 days ago</time-ago></figcaption><div class="clearfix"></div></li><li class="notification"><figure><div class="square">2</div></figure><figcaption><a data-notification-ids="61eac9770bdee0175f381627 61def487c09829003f3264af" href="https://www.codewars.com/users/61d7ec1260d73c0040c8f066">You have ranked up in JavaScript!</a><div class="ml-15px"></div><time-ago datetime="2022-01-21T14:55:51.949+0000" lang="en" title="2022年1月21日 GMT+8 下午10:55">5 days ago</time-ago></figcaption><div class="clearfix"></div></li><li class="notification"><figure><div rank="-6" class="small-hex is-extra-wide is-yellow-rank"><div class="inner-small-hex is-extra-wide "><span>6 kyu</span></div></div></figure><figcaption><a data-notification-ids="61eac9770bdee0175f381626" href="https://www.codewars.com/users/61d7ec1260d73c0040c8f066">Powerful you are. Your new overall rank is 6 kyu.</a><div class="ml-15px"></div><time-ago datetime="2022-01-21T14:55:51.926+0000" lang="en" title="2022年1月21日 GMT+8 下午10:55">5 days ago</time-ago></figcaption><div class="clearfix"></div></li><li class="notification"><figure><div rank="-7" class="small-hex is-extra-wide is-white-rank"><div class="inner-small-hex is-extra-wide "><span>7 kyu</span></div></div></figure><figcaption><a data-notification-ids="61def487c09829003f3264ae" href="https://www.codewars.com/users/61d7ec1260d73c0040c8f066">Respect. Your new overall rank is 7 kyu.</a><div class="ml-15px"></div><time-ago datetime="2022-01-12T15:32:23.916+0000" lang="en" title="2022年1月12日 GMT+8 下午11:32">14 days ago</time-ago></figcaption><div class="clearfix"></div></li><li class="notification"><figure><img title="zowietao" data-tippy-content="zowietao" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></figure><figcaption><a data-notification-ids="61e6d8bafcac0e00017afcee" href="https://www.codewars.com/users/61d7ec1260d73c0040c8f066">75+ Honor: You now have the ability to estimate the ranking of your own beta kata.</a><div class="ml-15px"></div><time-ago datetime="2022-01-18T15:11:54.956+0000" lang="en" title="2022年1月18日 GMT+8 下午11:11">8 days ago</time-ago></figcaption><div class="clearfix"></div></li><li class="notification"><figure><img title="zowietao" data-tippy-content="zowietao" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></figure><figcaption><a data-notification-ids="61e2ed7054e22a00012de07f" href="https://www.codewars.com/users/61d7ec1260d73c0040c8f066">50+ Honor: You now have the ability to mark comments as having spoiler code.</a><div class="ml-15px"></div><time-ago datetime="2022-01-15T15:51:12.208+0000" lang="en" title="2022年1月15日 GMT+8 下午11:51">11 days ago</time-ago></figcaption><div class="clearfix"></div></li><li class="notification"><figure><img title="zowietao" data-tippy-content="zowietao" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></figure><figcaption><a data-notification-ids="61def487f176470001d69226" href="https://www.codewars.com/users/61d7ec1260d73c0040c8f066">25+ Honor: You now have the ability to vote on beta kata.</a><div class="ml-15px"></div><time-ago datetime="2022-01-12T15:32:23.976+0000" lang="en" title="2022年1月12日 GMT+8 下午11:32">14 days ago</time-ago></figcaption><div class="clearfix"></div></li></ul></div></div></div></li><li class="profile-item min-w-60px sm:min-w-130px has-menu mr-0 text-sm"><a href="https://www.codewars.com/users/zowietao" id="header_profile_link"><div class="profile-pic mr-0"><img title="" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></div><div class="profile-points hidden sm:block ml-4"><div class="small-hex is-extra-wide is-invertable is-yellow-rank"><div class="inner-small-hex is-extra-wide "><span>6 kyu</span></div></div><div class="ml-10px is-inline" data-rt="61d7ec1260d73c0040c8f066:honor">134</div></div></a><div class="menu shadow-lg"><div class="menu-body" style="max-height: 720px;"><ul><li><a href="https://www.codewars.com/users/zowietao"><i class="icon-moon-user "></i>View Profile</a></li><li class="border-t"><a href="https://www.codewars.com/users/edit"><i class="icon-moon-settings "></i>Account Settings</a></li><li><a href="https://www.codewars.com/trainer/setup"><i class="icon-moon-settings "></i>Training Setup</a></li><li class="border-t"><a data-turbolinks="false" href="https://www.codewars.com/subscription"><i class="icon-moon-red-badge is-red-text"></i>Upgrade to Red</a></li><li class="border-t"><a class="js-sign-out"><i class="icon-moon-power "></i>Sign out</a></li></ul></div></div></li></ul></header><main id="shell_content" role="main"><div class="is-hidden" id="global_alerts"><div class="alert-box"></div></div><div id="flash"></div><div class="px-0 w-full"><div class="flex flex-col md:flex-row md:justify-between md:items-center px-2 md:px-4 py-2 mb-0 bg-ui-section"><div class="w-full md:w-5/12"><div class="flex items-center"><div class="small-hex is-extra-wide is-yellow-rank"><div class="inner-small-hex is-extra-wide "><span>5 kyu</span></div></div><h4 class="ml-4 mb-3">First non-repeating character</h4></div><div class="mt-1 mb-3" data-id="52bc74d4ac05d0945d00054e"><a class="mr-0 js-remove-code-challenge-star is-hidden" data-tippy-content="Total times this kata has been bookmarked. Click to remove your bookmark" data-tippy-placement="bottom"><i class="icon-moon-star text-sm opacity-75" rt="52bc74d4ac05d0945d00054e:total_stars"></i><span data-rt="52bc74d4ac05d0945d00054e:total_stars">709</span></a><a class="mr-0 js-add-code-challenge-star" data-tippy-content="Total times this kata has been bookmarked. Click to bookmark" data-tippy-placement="bottom"><i class="icon-moon-star-empty text-sm opacity-75" rt="52bc74d4ac05d0945d00054e:total_stars"></i><span data-rt="52bc74d4ac05d0945d00054e:total_stars">709</span></a><a class="mr-0 js-add-to-collection ml-2" data-challenge="{&quot;id&quot;:&quot;52bc74d4ac05d0945d00054e&quot;,&quot;name&quot;:&quot;First non-repeating character&quot;}" data-tippy-content="Total collections this kata is a part of. Click to view and add collections." data-tippy-placement="bottom"><i class="icon-moon-collection text-sm opacity-75" rt="52bc74d4ac05d0945d00054e:total_collections"></i><span data-rt="52bc74d4ac05d0945d00054e:total_collections">179</span></a><span class="ml-4 mr-0 text-ui-text-lc" data-tippy-content="Satisfaction Rating: 89% of users gave a positive rating out of 3692 votes. Ranked kata must be completed before they can be voted on." data-tippy-placement="bottom"><i class="icon-moon-guage text-xs opacity-75 top-0"></i><span class="mr-0">89% <span class="opacity-75">of</span> 3,692</span></span><span class="ml-4 mr-0 text-ui-text-lc" data-tippy-content="Total times JavaScript has been completed out of all kata completions" data-tippy-placement="bottom"><i class="icon-moon-bullseye text-sm opacity-75"></i>12,616 <span class="opacity-75">of</span> 34,779</span><a class="ml-4 mr-0" data-tippy-content="This kata&#39;s Sensei" data-tippy-placement="bottom" href="https://www.codewars.com/users/OverZealous"><i class="icon-moon-user text-sm opacity-75"></i>OverZealous</a></div></div><div class="w-full md:w-7/12"><div class="flex flex-col sm:flex-row sm:justify-around sm:items-center px-8 md:px-0"><div class="w-full sm:w-1/3"><div class="w-180px mx-auto"><div class="dropdown has-border p-4 shadow-sm" id="language_dd"><i class="icon-moon-chevron-sign-down"></i><span class="mr-4"><i class="icon-moon-javascript "></i>JavaScript</span><div class="placeholder">Choose language...</div><dl class="overflow-auto"><dd data-href="/kata/52bc74d4ac05d0945d00054e/solutions/csharp" data-load="" data-value="csharp"><i class="icon-moon-csharp "></i>C#</dd><dd data-href="/kata/52bc74d4ac05d0945d00054e/solutions/fsharp" data-load="" data-value="fsharp"><i class="icon-moon-fsharp "></i>F#</dd><dd data-href="/kata/52bc74d4ac05d0945d00054e/solutions/go" data-load="" data-value="go"><i class="icon-moon-go "></i>Go</dd><dd data-load="" data-value="javascript"><i class="icon-moon-javascript "></i>JavaScript</dd><dd data-href="/kata/52bc74d4ac05d0945d00054e/solutions/ocaml" data-load="" data-value="ocaml"><i class="icon-moon-ocaml "></i>OCaml (Beta)</dd><dd data-href="/kata/52bc74d4ac05d0945d00054e/solutions/python" data-load="" data-value="python"><i class="icon-moon-python "></i>Python</dd><dd data-href="/kata/52bc74d4ac05d0945d00054e/solutions/ruby" data-load="" data-value="ruby"><i class="icon-moon-ruby "></i>Ruby</dd><dd class="border-t" data-href="/kata/52bc74d4ac05d0945d00054e/translations" data-load=""><i class="icon-moon-plus "></i>Add New</dd></dl></div></div></div><div class="w-full sm:w-2/3 py-2 md:py-0"><div class="text-center md:text-right whitespace-nowrap"><a class="btn is-dark" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/train/javascript" id="replay_btn" title="Take this kata again. Try to beat your best time or attempt another language!"><i class="icon-moon-refresh "></i>Train Again</a><a class="btn ml-1 sm:ml-2" href="https://www.codewars.com/trainer/javascript" id="play_next_btn" title="Train on another challenge"><i class="icon-moon-play "></i>Next Kata</a></div></div></div></div></div></div><div class="w-full clear-both mt-2"><div class="flex flex-row justify-between"><ul class="flex flex-row justify-center items-center space-x-5 px-2 border-0 h-10"><li class="flex items-center border-b border-transparent"><a href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/javascript">Details</a></li><li class="flex items-center border-b font-bold"><a id="solutions"><i class="icon-moon-bullseye "></i>Solutions</a></li><li class="flex items-center border-b border-transparent"><a href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/forks/javascript"><i class="icon-moon-forked "></i>Forks (15)</a></li><li class="flex items-center border-b border-transparent"><a href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/discuss/javascript"><i class="icon-moon-comments "></i>Discourse (260)</a></li><li class="flex items-center border-b border-transparent"><a href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/translations"><i class="icon-moon-translation "></i>Translations</a></li></ul><div class="js-train-social mt-2 hidden md:block"><a class="js-fork-current-language" data-tippy-content="Fork the current version of the selected language to propose changes" data-tippy-placement="bottom" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/fork/javascript"><i class="icon-moon-forked "></i>Fork</a><span class="mx-4 opacity-25">|</span><a class="js-add-to-collection" data-challenge="{&quot;id&quot;:&quot;52bc74d4ac05d0945d00054e&quot;,&quot;name&quot;:&quot;First non-repeating character&quot;}"><i class="icon-moon-collection "></i>Collect</a><span class="mx-4 opacity-25">|</span><a class="js-share-email is-alt" href="mailto:?subject=Take%20the%20Codewars%20challenge%21&amp;body=Hey%2C%0A%0AI%20just%20completed%20training%20on%20%22First%20non-repeating%20character%22%20https%3A%2F%2Fwww.codewars.com%2F%2Fkata%2F52bc74d4ac05d0945d00054e%2Fjavascript%0AIf%20you%27re%20not%20a%20member%20yet%2C%20join%20me%20and%20start%20training%20at%20https%3A%2F%2Fwww.codewars.com%2Fr%2FzFjO0A%0A" target="_blank"><i class="icon-moon-envelope "></i></a><a class="js-share-twitter ml-1 is-alt" data-share-text="I solved the &quot;Algorithm&quot; kata! Take the code initiation @ codewars.com/r/zFjO0A to enlist and challenge yourself. #codewars"><i class="icon-moon-twitter "></i></a><a class="js-share-facebook ml-1 mr-2 is-alt" data-share-body="I solved the &quot;First non-repeating character&quot; kata!" data-share-title="Take the Codewars challenge to enlist!"><i class="icon-moon-facebook "></i></a></div></div><view id="vote_feedback" class="js-rendered"><script type="template"><div class="panel bg-ui-section mb-15px" data-bind-if="$permissions.vote &amp;&amp; $completedKata" id="vote_info"><span><i class="icon-moon-guage "></i>How satisfied are you with this kata?</span><ul class="vote-assessment is-inline ml-15px align-middle"><li data-bind-class="$vote | gt :: 0 | active_class" data-value="1"><a class="btn"><i class="icon-moon-happy "></i>Very</a></li><li data-bind-class="$vote | eq :: 0 | active_class" data-value="0"><a class="btn"><i class="icon-moon-blankstare "></i>Somewhat</a></li><li data-bind-class="$vote | eq :: -1 | active_class" data-value="-1"><a class="btn"><i class="icon-moon-sad "></i>None</a></li></ul><div class="clearfix"></div></div></script><div class="view" data-context="root"><div class="panel bg-ui-section mb-15px" id="vote_info"><span><i class="icon-moon-guage "></i>How satisfied are you with this kata?</span><ul class="vote-assessment is-inline ml-15px align-middle"><li data-value="1"><a class="btn"><i class="icon-moon-happy "></i>Very</a></li><li data-value="0"><a class="btn"><i class="icon-moon-blankstare "></i>Somewhat</a></li><li data-value="-1"><a class="btn"><i class="icon-moon-sad "></i>None</a></li></ul><div class="clearfix"></div></div></div></view><div class="has-centered-text mb-15px" id="toggle_description"><div class="alert-box alert-box--dark no-border"><a>Show Kata Description</a></div></div><div class="description is-full-height has-auto-scrolling is-hidden mb-15px p-15px bg-ui-section" id="description_panel"><h5>Description:</h5><div class="markdown prose max-w-none" id="description">Loading description...</div><div class="mt-15px"><span><i class="icon-moon-tag "></i></span><div class="keyword-tag">Algorithms</div><div class="keyword-tag">Strings</div><div class="keyword-tag">Search</div></div><p class="mt-15px"><a class="float-right" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/discuss/javascript">Suggest kata description edits</a></p></div><div class="has-centered-text mb-15px" id="toggle_fixture"><div class="alert-box alert-box--dark no-border"><a>Show Kata Test Cases</a></div></div><div class="description is-full-height has-auto-scrolling mb-15px p-15px bg-ui-section is-hidden" id="fixture_panel"><h5>Test Cases:</h5><pre class="p-2 overflow-x-auto"><code data-language="javascript"><span class="cm-variable">describe</span>(<span class="cm-string">'Simple Tests'</span>, <span class="cm-keyword">function</span>() {
  <span class="cm-variable">it</span>(<span class="cm-string">'should handle simple tests'</span>, <span class="cm-keyword">function</span>() {
    <span class="cm-variable">Test</span>.<span class="cm-property">assertEquals</span>(<span class="cm-variable">firstNonRepeatingLetter</span>(<span class="cm-string">'a'</span>), <span class="cm-string">'a'</span>);
    <span class="cm-variable">Test</span>.<span class="cm-property">assertEquals</span>(<span class="cm-variable">firstNonRepeatingLetter</span>(<span class="cm-string">'stress'</span>), <span class="cm-string">'t'</span>);
    <span class="cm-variable">Test</span>.<span class="cm-property">assertEquals</span>(<span class="cm-variable">firstNonRepeatingLetter</span>(<span class="cm-string">'moonmen'</span>), <span class="cm-string">'e'</span>);
  });
  <span class="cm-variable">it</span>(<span class="cm-string">'should handle empty strings'</span>, <span class="cm-keyword">function</span>() {
    <span class="cm-variable">Test</span>.<span class="cm-property">assertEquals</span>(<span class="cm-variable">firstNonRepeatingLetter</span>(<span class="cm-string">''</span>), <span class="cm-string">''</span>);
  });
});

<span class="cm-variable">describe</span>(<span class="cm-string">'Harder Tests'</span>, <span class="cm-keyword">function</span>() {
  <span class="cm-variable">it</span>(<span class="cm-string">'should handle all repeating strings'</span>, <span class="cm-keyword">function</span>() {
    <span class="cm-variable">Test</span>.<span class="cm-property">assertEquals</span>(<span class="cm-variable">firstNonRepeatingLetter</span>(<span class="cm-string">'abba'</span>), <span class="cm-string">''</span>);
    <span class="cm-variable">Test</span>.<span class="cm-property">assertEquals</span>(<span class="cm-variable">firstNonRepeatingLetter</span>(<span class="cm-string">'aa'</span>), <span class="cm-string">''</span>);
  });
  <span class="cm-variable">it</span>(<span class="cm-string">'should handle odd characters'</span>, <span class="cm-keyword">function</span>() {
    <span class="cm-variable">Test</span>.<span class="cm-property">assertEquals</span>(<span class="cm-variable">firstNonRepeatingLetter</span>(<span class="cm-string">'∞§ﬁ›ﬂ∞§'</span>), <span class="cm-string">'ﬁ'</span>);
    <span class="cm-variable">Test</span>.<span class="cm-property">assertEquals</span>(<span class="cm-variable">firstNonRepeatingLetter</span>(<span class="cm-string">'hello world, eh?'</span>), <span class="cm-string">'w'</span>);
  });
  <span class="cm-variable">it</span>(<span class="cm-string">'should handle letter cases'</span>, <span class="cm-keyword">function</span>() {
    <span class="cm-variable">Test</span>.<span class="cm-property">assertEquals</span>(<span class="cm-variable">firstNonRepeatingLetter</span>(<span class="cm-string">'sTreSS'</span>), <span class="cm-string">'T'</span>);
    <span class="cm-variable">Test</span>.<span class="cm-property">assertEquals</span>(<span class="cm-variable">firstNonRepeatingLetter</span>(<span class="cm-string">'Go hang a salami, I\'m a lasagna hog!'</span>), <span class="cm-string">','</span>);
  });
});

<span class="cm-variable">describe</span>(<span class="cm-string">'Random Tests'</span>, <span class="cm-keyword">function</span>() {
  <span class="cm-keyword">var</span> <span class="cm-def">unique</span> <span class="cm-operator">=</span> <span class="cm-variable">Test</span>.<span class="cm-property">randomToken</span>()[<span class="cm-number">0</span>],
      <span class="cm-def">rep</span> <span class="cm-operator">=</span> <span class="cm-keyword">new</span> <span class="cm-variable">RegExp</span>(<span class="cm-variable-2">unique</span>, <span class="cm-string">'g'</span>),
      <span class="cm-def">s</span> <span class="cm-operator">=</span> <span class="cm-string">''</span>, <span class="cm-def">temp</span>;
  <span class="cm-keyword">while</span>(<span class="cm-variable-2">s</span>.<span class="cm-property">length</span> <span class="cm-operator">&lt;</span> <span class="cm-number">100</span>) {
    <span class="cm-variable-2">temp</span> <span class="cm-operator">=</span> <span class="cm-variable">Test</span>.<span class="cm-property">randomToken</span>().<span class="cm-property">replace</span>(<span class="cm-variable-2">rep</span>, <span class="cm-string">''</span>);
    <span class="cm-variable-2">s</span> <span class="cm-operator">+=</span> <span class="cm-variable-2">temp</span> <span class="cm-operator">+</span> <span class="cm-variable-2">temp</span>;
  }
  <span class="cm-variable-2">s</span> <span class="cm-operator">+=</span> <span class="cm-variable-2">unique</span>;
  <span class="cm-variable">it</span>(<span class="cm-string">'should handle random input'</span>, <span class="cm-keyword">function</span>() {
    <span class="cm-variable">Test</span>.<span class="cm-property">assertEquals</span>(<span class="cm-variable">firstNonRepeatingLetter</span>(<span class="cm-variable-2">s</span>), <span class="cm-variable-2">unique</span>, <span class="cm-variable">console</span>.<span class="cm-property">log</span>(<span class="cm-string">'Expecting &lt;code&gt;\''</span><span class="cm-operator">+</span><span class="cm-variable-2">unique</span><span class="cm-operator">+</span><span class="cm-string">'\'&lt;/code&gt; on input of &lt;pre&gt;'</span><span class="cm-operator">+</span><span class="cm-variable-2">s</span><span class="cm-operator">+</span><span class="cm-string">'&lt;/pre&gt;'</span>));
  });
});</code></pre><p class="mt-15px"><a class="float-right" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/discuss/javascript">Suggest test case edits</a></p></div><div class="pb-5px bg-ui-section"><div class="solution-filter pt-10px px-10px"><ul class="piped-text mb-30px use-alt-active-color"><li><b>Show Me:</b></li><li data-tippy-content="Show everyone&#39;s solutions" data-tippy-placement="top"><a class="is-active" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript/all/best_practice">All Solutions</a></li><li data-tippy-content="Show the solutions of those that I am following" data-tippy-placement="top"><a href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript/following/best_practice">Solutions of Users I am Following</a></li><li data-tippy-content="Only show my solutions" data-tippy-placement="top"><a href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript/me/best_practice">My Solutions</a></li></ul><div class="clearfix"></div><ul class="piped-text mb-30px use-alt-active-color"><li><b>Sort By:</b></li><li data-tippy-content="Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="top"><a class="is-active" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript/all/best_practices">Best Practices</a></li><li data-tippy-content="Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="top"><a href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript/all/clever">Clever</a></li><li><a href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript/all/newest">Newest</a></li><li><a href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript/all/oldest">Oldest</a></li></ul><div class="clearfix"></div></div><div class="px-15px"><ul class="is-unstyled items-have-border-bottom mb-0" id="solutions_list"><li class="js-result-group pb-30px mb-30px" data-controller="solution-group" data-solution-group-group-id-value="5387b2beee8452489900056a" data-solution-group-review-id-value="52bc74d4ac05d0945d000551" id="5387b2beee8452489900056a"><h6><i class="icon-moon-users "></i><a class="font-semibold" href="https://www.codewars.com/users/pirino.hamster">pirino.hamster</a><span>, </span><a href="https://www.codewars.com/users/LiuNguyen">LiuNguyen</a><span>, </span><a href="https://www.codewars.com/users/lajek">lajek</a><span>, </span><a href="https://www.codewars.com/users/14bce128@nirmauni.ac.in">14bce128@nirmauni.ac.in</a><span>, </span><a href="https://www.codewars.com/users/user9930045">user9930045</a><span>, </span><a href="https://www.codewars.com/users/hawkf">hawkf</a><span>, </span><a href="https://www.codewars.com/users/max_asia">max_asia</a><span>, </span><a href="https://www.codewars.com/users/igof">igof</a><span>, </span><a href="https://www.codewars.com/users/lee.peavy">lee.peavy</a><span>, </span><a href="https://www.codewars.com/users/qwerty123654">qwerty123654</a><span> (plus 26 more warriors)</span><div class="clearfix"></div></h6><pre class="p-2 overflow-x-auto"><code data-language="javascript"><span class="cm-keyword">function</span> <span class="cm-def">firstNonRepeatingLetter</span>(<span class="cm-def">s</span>) {
  <span class="cm-keyword">for</span>(<span class="cm-keyword">var</span> <span class="cm-def">i</span> <span class="cm-keyword">in</span> <span class="cm-variable-2">s</span>) {
    <span class="cm-keyword">if</span>(<span class="cm-variable-2">s</span>.<span class="cm-property">match</span>(<span class="cm-keyword">new</span> <span class="cm-variable">RegExp</span>(<span class="cm-variable-2">s</span>[<span class="cm-variable-2">i</span>],<span class="cm-string">"gi"</span>)).<span class="cm-property">length</span> <span class="cm-operator">===</span> <span class="cm-number">1</span>) {
      <span class="cm-keyword">return</span> <span class="cm-variable-2">s</span>[<span class="cm-variable-2">i</span>];
    }
  }
  <span class="cm-keyword">return</span> <span class="cm-string">''</span>;
}</code></pre><div data-controller="solution-variations" data-solution-variations-group-id-value="5387b2beee8452489900056a" data-solution-variations-review-id-value="52bc74d4ac05d0945d000551"><div class="mt-4 mb-0 px-1 text-ui-text-lc flex justify-between"><div>15 similar code variations are grouped with this one<i class="icon-moon-info ml-1" data-tippy-content="We group similar results by ignoring whitespace, linebreaks and very minor character variations." data-tippy-placement="bottom"></i></div><button class="hidden sm:block" data-action="solution-variations#toggle">Show Variations</button></div><div class="has-top-border mt-4 pt-4 is-hidden space-y-4" data-solution-variations-target="container"></div></div><div class="js-compare is-hidden" data-template="#_compare_solution"></div><div class="clearfix"></div><view data-view-data="{&quot;comments&quot;:[{&quot;id&quot;:&quot;60fd016e4c067d000d03e211&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;60f3bf3a8fd43a00440c5035&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;60f3bf3a8fd43a00440c5035&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;would break for chars like ?&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003ewould break for chars like ?\u003c/p\u003e&quot;,&quot;created_at&quot;:1627193710,&quot;created_at_datetime&quot;:&quot;2021-07-25T06:15:10.206+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#60fd016e4c067d000d03e211&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;60f3bf3a8fd43a00440c5035&quot;,&quot;username&quot;:&quot;Tom-Hudson&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/Tom-Hudson&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;Tom-Hudson\&quot; data-tippy-content=\&quot;Tom-Hudson\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/26221061?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;6016b72d287c520018f7dc2d&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:-2,&quot;user_id&quot;:&quot;5fb0a72350e71900176891c3&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5fb0a72350e71900176891c3&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;if you use regex to solve 5th kyu probs on here i dont like u&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eif you use regex to solve 5th kyu probs on here i dont like u\u003c/p\u003e&quot;,&quot;created_at&quot;:1612101421,&quot;created_at_datetime&quot;:&quot;2021-01-31T13:57:01.710+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:true,&quot;total_comments&quot;:2,&quot;hash&quot;:&quot;#6016b72d287c520018f7dc2d&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5fb0a72350e71900176891c3&quot;,&quot;username&quot;:&quot;dogma-n&quot;,&quot;rank_name&quot;:&quot;2 kyu&quot;,&quot;profile_path&quot;:&quot;/users/dogma-n&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;dogma-n\&quot; data-tippy-content=\&quot;dogma-n\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/73856080?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[{&quot;id&quot;:&quot;61203dcf27e7220007500e80&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;604769b4aaf2fd0019fcafc9&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;604769b4aaf2fd0019fcafc9&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;What&#39;s wrong with Regex? I&#39;d say it&#39;s fine to use whatever method as long as it&#39;s natively build into javascript (not importing a library) and it&#39;s not forbidden by the author.&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eWhat&#39;s wrong with Regex? I&#39;d say it&#39;s fine to use whatever method as long as it&#39;s natively build into javascript (not importing a library) and it&#39;s not forbidden by the author.\u003c/p\u003e&quot;,&quot;created_at&quot;:1629502927,&quot;created_at_datetime&quot;:&quot;2021-08-20T23:42:07.498+0000&quot;,&quot;nest_level&quot;:1,&quot;collapsed&quot;:false,&quot;total_comments&quot;:null,&quot;hash&quot;:&quot;#61203dcf27e7220007500e80&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;604769b4aaf2fd0019fcafc9&quot;,&quot;username&quot;:&quot;farhanaditya&quot;,&quot;rank_name&quot;:&quot;1 kyu&quot;,&quot;profile_path&quot;:&quot;/users/farhanaditya&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;farhanaditya\&quot; data-tippy-content=\&quot;farhanaditya\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://www.codewars.com/packs/assets/profile-pic.f3a90aca.png\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;6122694f01ef9f003f9c810e&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:0,&quot;user_id&quot;:&quot;5fb0a72350e71900176891c3&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5fb0a72350e71900176891c3&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;regex bad&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eregex bad\u003c/p\u003e&quot;,&quot;created_at&quot;:1629645135,&quot;created_at_datetime&quot;:&quot;2021-08-22T15:12:15.063+0000&quot;,&quot;nest_level&quot;:1,&quot;collapsed&quot;:false,&quot;total_comments&quot;:null,&quot;hash&quot;:&quot;#6122694f01ef9f003f9c810e&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5fb0a72350e71900176891c3&quot;,&quot;username&quot;:&quot;dogma-n&quot;,&quot;rank_name&quot;:&quot;2 kyu&quot;,&quot;profile_path&quot;:&quot;/users/dogma-n&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;dogma-n\&quot; data-tippy-content=\&quot;dogma-n\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/73856080?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]}]},{&quot;id&quot;:&quot;6010a457793857001df172b8&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:3,&quot;user_id&quot;:&quot;5fdcb330521370000ee710d7&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5fdcb330521370000ee710d7&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Excellent solution. I think imperatively, I must spend a year in the temple with the honorable declarative monks.&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eExcellent solution. I think imperatively, I must spend a year in the temple with the honorable declarative monks.\u003c/p\u003e&quot;,&quot;created_at&quot;:1611703383,&quot;created_at_datetime&quot;:&quot;2021-01-26T23:23:03.465+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#6010a457793857001df172b8&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5fdcb330521370000ee710d7&quot;,&quot;username&quot;:&quot;karaeg-san&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/karaeg-san&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;karaeg-san\&quot; data-tippy-content=\&quot;karaeg-san\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/16840272?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5f8d90dbf130ea00290f4d26&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;5f1aabd3889c640016924001&quot;,&quot;edit_count&quot;:2,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5f1aabd3889c640016924001&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Very nice !\n\nI wanted to use recursion to solve this. I could have done it using .search() method instead of .match() (don&#39;t know which is better). &quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eVery nice !\u003c/p\u003e\n\u003cp\u003eI wanted to use recursion to solve this. I could have done it using .search() method instead of .match() (don&#39;t know which is better).\u003c/p\u003e&quot;,&quot;created_at&quot;:1603113179,&quot;created_at_datetime&quot;:&quot;2020-10-19T13:12:59.938+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#5f8d90dbf130ea00290f4d26&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5f1aabd3889c640016924001&quot;,&quot;username&quot;:&quot;smolair0377&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/smolair0377&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;smolair0377\&quot; data-tippy-content=\&quot;smolair0377\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/61193297?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5f49103c1263340024dc9b8f&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:2,&quot;user_id&quot;:&quot;5f4157c218330d001509a8ef&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5f4157c218330d001509a8ef&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Clever, indeed.\n\nI chose a different, slightly longer path counting each character in the string and everything, which is not as cool as this one. Good job.&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eClever, indeed.\u003c/p\u003e\n\u003cp\u003eI chose a different, slightly longer path counting each character in the string and everything, which is not as cool as this one. Good job.\u003c/p\u003e&quot;,&quot;created_at&quot;:1598623804,&quot;created_at_datetime&quot;:&quot;2020-08-28T14:10:04.609+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#5f49103c1263340024dc9b8f&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5f4157c218330d001509a8ef&quot;,&quot;username&quot;:&quot;c99.rahul&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/c99.rahul&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;c99.rahul\&quot; data-tippy-content=\&quot;c99.rahul\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://www.codewars.com/packs/assets/profile-pic.f3a90aca.png\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5e62e81a6353a40016afc8d9&quot;,&quot;masked&quot;:false,&quot;masked_by_id&quot;:&quot;60638bc3dd3138003116627e&quot;,&quot;votes_score&quot;:4,&quot;user_id&quot;:&quot;5cbf789682d2030019c84592&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5cbf789682d2030019c84592&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;This solution is fine, but at 5 Kyu I think it is important to start considering efficiency and redability. This has polynomial complexity. Look at my solution for a linear complexity solution. Clever, but definitely not a \&quot;Best Practice\&quot;&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eThis solution is fine, but at 5 Kyu I think it is important to start considering efficiency and redability. This has polynomial complexity. Look at my solution for a linear complexity solution. Clever, but definitely not a \&quot;Best Practice\&quot;\u003c/p\u003e&quot;,&quot;created_at&quot;:1583540250,&quot;created_at_datetime&quot;:&quot;2020-03-07T00:17:30.359+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#5e62e81a6353a40016afc8d9&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5cbf789682d2030019c84592&quot;,&quot;username&quot;:&quot;Wolf Fivousix&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/Wolf%20Fivousix&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;Wolf Fivousix\&quot; data-tippy-content=\&quot;Wolf Fivousix\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://www.codewars.com/packs/assets/profile-pic.f3a90aca.png\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5d9d98be8b0f6c002286c65d&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:2,&quot;user_id&quot;:&quot;5d99c6455ec4c400199b4e22&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5d99c6455ec4c400199b4e22&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Good solution but there is more better solution.&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eGood solution but there is more better solution.\u003c/p\u003e&quot;,&quot;created_at&quot;:1570609342,&quot;created_at_datetime&quot;:&quot;2019-10-09T08:22:22.339+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#5d9d98be8b0f6c002286c65d&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5d99c6455ec4c400199b4e22&quot;,&quot;username&quot;:&quot;uksarkar&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/uksarkar&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;uksarkar\&quot; data-tippy-content=\&quot;uksarkar\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/19898129?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5c8ebfd236b59b430dca5c02&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;573b79f7301a2d0e5e0001fd&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;573b79f7301a2d0e5e0001fd&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Good to know for/in works on strings, but performing regex is iterating over the whole string, so this becomes exponential time complexity.&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eGood to know for/in works on strings, but performing regex is iterating over the whole string, so this becomes exponential time complexity.\u003c/p\u003e&quot;,&quot;created_at&quot;:1552859099,&quot;created_at_datetime&quot;:&quot;2019-03-17T21:44:59.702+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#5c8ebfd236b59b430dca5c02&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;573b79f7301a2d0e5e0001fd&quot;,&quot;username&quot;:&quot;jazzyjackson&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/jazzyjackson&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;jazzyjackson\&quot; data-tippy-content=\&quot;jazzyjackson\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/7675670?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5c360c51fdcefd393e71c703&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;59ca569672851ede840000c4&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;59ca569672851ede840000c4&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;using a Map did it for me...nice solution!&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eusing a Map did it for me...nice solution!\u003c/p\u003e&quot;,&quot;created_at&quot;:1547045969,&quot;created_at_datetime&quot;:&quot;2019-01-09T14:59:29.171+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#5c360c51fdcefd393e71c703&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;59ca569672851ede840000c4&quot;,&quot;username&quot;:&quot;juanlet&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/juanlet&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;juanlet\&quot; data-tippy-content=\&quot;juanlet\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/12257699?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5c303697fc5e550014234770&quot;,&quot;masked&quot;:true,&quot;masked_by_id&quot;:&quot;5bea34f52635539d29000150&quot;,&quot;votes_score&quot;:3,&quot;user_id&quot;:&quot;5bea34f52635539d29000150&quot;,&quot;edit_count&quot;:1,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5bea34f52635539d29000150&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;brought this back into the kata and saw that it didnt break for &#39;?&#39; and i have no idea why.\n\nI had to create a conditional to add a \\ to special characters in order to pass the test including &#39;?&#39; when creating my solution my solution and on the surface this seems to be doing almost the same thing. Would love to understand how this doesnt create the RegExp: /?/gi which would be invalid.\n\nEDIT: apparently running his solution somehow overwrote mine but it I had created a variable called regSplit which split the string into an array of regexps using .map and then used .match on the string until it returned a result with a length of 1&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003ebrought this back into the kata and saw that it didnt break for &#39;?&#39; and i have no idea why.\u003c/p\u003e\n\u003cp\u003eI had to create a conditional to add a \\ to special characters in order to pass the test including &#39;?&#39; when creating my solution my solution and on the surface this seems to be doing almost the same thing. Would love to understand how this doesnt create the RegExp: /?/gi which would be invalid.\u003c/p\u003e\n\u003cp\u003eEDIT: apparently running his solution somehow overwrote mine but it I had created a variable called regSplit which split the string into an array of regexps using .map and then used .match on the string until it returned a result with a length of 1\u003c/p\u003e&quot;,&quot;created_at&quot;:1546663575,&quot;created_at_datetime&quot;:&quot;2019-01-05T04:46:15.761+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#5c303697fc5e550014234770&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5bea34f52635539d29000150&quot;,&quot;username&quot;:&quot;Camstew7&quot;,&quot;rank_name&quot;:&quot;4 kyu&quot;,&quot;profile_path&quot;:&quot;/users/Camstew7&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;Camstew7\&quot; data-tippy-content=\&quot;Camstew7\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/44987487?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5bebdf4ed415659bb000007d&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:2,&quot;user_id&quot;:&quot;5bd803ebb0eb75748c0003a1&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5bd803ebb0eb75748c0003a1&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Not working with string containing \&quot;?\&quot; symbol, as in test&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eNot working with string containing \&quot;?\&quot; symbol, as in test\u003c/p\u003e&quot;,&quot;created_at&quot;:1542184782,&quot;created_at_datetime&quot;:&quot;2018-11-14T08:39:42.772+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:true,&quot;total_comments&quot;:1,&quot;hash&quot;:&quot;#5bebdf4ed415659bb000007d&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5bd803ebb0eb75748c0003a1&quot;,&quot;username&quot;:&quot;trajan&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/trajan&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;trajan\&quot; data-tippy-content=\&quot;trajan\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://www.codewars.com/packs/assets/profile-pic.f3a90aca.png\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[{&quot;id&quot;:&quot;5c9cbef644ef464e331acd0c&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;5c7e72f5114f7b52616ae77a&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5c7e72f5114f7b52616ae77a&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Yes. Test is completed because &#39;?&#39; after correct symbol :)&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eYes. Test is completed because &#39;?&#39; after correct symbol :)\u003c/p\u003e&quot;,&quot;created_at&quot;:1553776376,&quot;created_at_datetime&quot;:&quot;2019-03-28T12:32:56.607+0000&quot;,&quot;nest_level&quot;:1,&quot;collapsed&quot;:false,&quot;total_comments&quot;:null,&quot;hash&quot;:&quot;#5c9cbef644ef464e331acd0c&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5c7e72f5114f7b52616ae77a&quot;,&quot;username&quot;:&quot;slider27276&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/slider27276&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;slider27276\&quot; data-tippy-content=\&quot;slider27276\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://www.codewars.com/packs/assets/profile-pic.f3a90aca.png\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]}]},{&quot;id&quot;:&quot;5b515302bdd0744820000090&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;5b4ff8d2bdd07497990007cc&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5b4ff8d2bdd07497990007cc&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Nice easy way to do this if you can solve the problem mentioned for special characters.  &#39;\\&#39; will be the hardest character to deal with I think.\n\nOne downside to your approach is that it has exponential time complexity, so if you were to have 100,000 characters, worst case would be at least 10,000,000,000 operations, which would be too slow for most situations.\n\nOf course, most of the time you probably won&#39;t deal with input that large.  :)&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eNice easy way to do this if you can solve the problem mentioned for special characters.  &#39;&#39; will be the hardest character to deal with I think.\u003c/p\u003e\n\u003cp\u003eOne downside to your approach is that it has exponential time complexity, so if you were to have 100,000 characters, worst case would be at least 10,000,000,000 operations, which would be too slow for most situations.\u003c/p\u003e\n\u003cp\u003eOf course, most of the time you probably won&#39;t deal with input that large.  :)\u003c/p\u003e&quot;,&quot;created_at&quot;:1532056322,&quot;created_at_datetime&quot;:&quot;2018-07-20T03:12:02.962+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#5b515302bdd0744820000090&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5b4ff8d2bdd07497990007cc&quot;,&quot;username&quot;:&quot;snydergd&quot;,&quot;rank_name&quot;:&quot;6 kyu&quot;,&quot;profile_path&quot;:&quot;/users/snydergd&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;snydergd\&quot; data-tippy-content=\&quot;snydergd\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/1040083?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5a61f19cfd56cb42a200004b&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:6,&quot;user_id&quot;:&quot;5583c8855ac5d93fda0000da&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5583c8855ac5d93fda0000da&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;This would break for special characters in the regex because they aren&#39;t escaped.\nIt only passes all of the tests because, fortunately, it finds a match before it hits the &#39;?&#39;.&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eThis would break for special characters in the regex because they aren&#39;t escaped.\u003cbr\u003e\nIt only passes all of the tests because, fortunately, it finds a match before it hits the &#39;?&#39;.\u003c/p\u003e&quot;,&quot;created_at&quot;:1516368284,&quot;created_at_datetime&quot;:&quot;2018-01-19T13:24:44.712+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:true,&quot;total_comments&quot;:1,&quot;hash&quot;:&quot;#5a61f19cfd56cb42a200004b&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5583c8855ac5d93fda0000da&quot;,&quot;username&quot;:&quot;rejam&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/rejam&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;rejam\&quot; data-tippy-content=\&quot;rejam\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://www.codewars.com/packs/assets/profile-pic.f3a90aca.png\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[{&quot;id&quot;:&quot;5ace8c44830617280d000084&quot;,&quot;masked&quot;:false,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:7,&quot;user_id&quot;:&quot;5a899395fd5777c96d000028&quot;,&quot;edit_count&quot;:1,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5a899395fd5777c96d000028&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Agreed. The new RegExp should go like this:\n```\nnew RegExp( \&quot;[\&quot; + s[i] + \&quot;]\&quot;, \&quot;gi\&quot;)\n\n&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eAgreed. The new RegExp should go like this:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003enew RegExp( \&quot;[\&quot; + s[i] + \&quot;]\&quot;, \&quot;gi\&quot;)\n\n\u003c/code\u003e\u003c/pre\u003e&quot;,&quot;created_at&quot;:1523485764,&quot;created_at_datetime&quot;:&quot;2018-04-11T22:29:24.397+0000&quot;,&quot;nest_level&quot;:1,&quot;collapsed&quot;:false,&quot;total_comments&quot;:null,&quot;hash&quot;:&quot;#5ace8c44830617280d000084&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5a899395fd5777c96d000028&quot;,&quot;username&quot;:&quot;Wildpat01&quot;,&quot;rank_name&quot;:&quot;4 kyu&quot;,&quot;profile_path&quot;:&quot;/users/Wildpat01&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;Wildpat01\&quot; data-tippy-content=\&quot;Wildpat01\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://www.codewars.com/packs/assets/profile-pic.f3a90aca.png\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]}]},{&quot;id&quot;:&quot;59274f94356e51500c00006c&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:2,&quot;user_id&quot;:&quot;5797b5667cb7a17aff00005d&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5797b5667cb7a17aff00005d&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;You might be getting lucky here, since there is no guaruntee that for...in will iterate over the characters in order. Am I missing something?&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eYou might be getting lucky here, since there is no guaruntee that for...in will iterate over the characters in order. Am I missing something?\u003c/p\u003e&quot;,&quot;created_at&quot;:1495748500,&quot;created_at_datetime&quot;:&quot;2017-05-25T21:41:40.217+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:true,&quot;total_comments&quot;:1,&quot;hash&quot;:&quot;#59274f94356e51500c00006c&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5797b5667cb7a17aff00005d&quot;,&quot;username&quot;:&quot;FMurray&quot;,&quot;rank_name&quot;:&quot;6 kyu&quot;,&quot;profile_path&quot;:&quot;/users/FMurray&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;FMurray\&quot; data-tippy-content=\&quot;FMurray\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/5853331?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[{&quot;id&quot;:&quot;5935e2d452e1c6392600005f&quot;,&quot;masked&quot;:true,&quot;masked_by_id&quot;:&quot;59343229cff4acb1930001ee&quot;,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;59343229cff4acb1930001ee&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;59343229cff4acb1930001ee&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;As i understood it, iterating is done at the for(var i in s)..could of used a for loop like i did, and then its simply looking for the first character to only match 1.&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eAs i understood it, iterating is done at the for(var i in s)..could of used a for loop like i did, and then its simply looking for the first character to only match 1.\u003c/p\u003e&quot;,&quot;created_at&quot;:1496703700,&quot;created_at_datetime&quot;:&quot;2017-06-05T23:01:40.931+0000&quot;,&quot;nest_level&quot;:1,&quot;collapsed&quot;:false,&quot;total_comments&quot;:null,&quot;hash&quot;:&quot;#5935e2d452e1c6392600005f&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;59343229cff4acb1930001ee&quot;,&quot;username&quot;:&quot;KevCJones&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/KevCJones&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;KevCJones\&quot; data-tippy-content=\&quot;KevCJones\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/696048?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]}]},{&quot;id&quot;:&quot;58c8f378bd1c2471600000f8&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;58c4ccb4e4eb57e9020000e1&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;58c4ccb4e4eb57e9020000e1&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;clever!&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eclever!\u003c/p\u003e&quot;,&quot;created_at&quot;:1489564536,&quot;created_at_datetime&quot;:&quot;2017-03-15T07:55:36.641+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#58c8f378bd1c2471600000f8&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;58c4ccb4e4eb57e9020000e1&quot;,&quot;username&quot;:&quot;MrZhangFengfeng&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/MrZhangFengfeng&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;MrZhangFengfeng\&quot; data-tippy-content=\&quot;MrZhangFengfeng\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/24266779?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5798a54839f33ae28300031c&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:5,&quot;user_id&quot;:&quot;577accf8d48e51ce49000214&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;577accf8d48e51ce49000214&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Didn&#39;t know you could iterate through a string that way. We learn something new everyday! :)\n\nGood job sir!&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eDidn&#39;t know you could iterate through a string that way. We learn something new everyday! :)\u003c/p\u003e\n\u003cp\u003eGood job sir!\u003c/p\u003e&quot;,&quot;created_at&quot;:1469621576,&quot;created_at_datetime&quot;:&quot;2016-07-27T12:12:56.256+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#5798a54839f33ae28300031c&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;577accf8d48e51ce49000214&quot;,&quot;username&quot;:&quot;HotOffTheCouchPotato&quot;,&quot;rank_name&quot;:&quot;3 kyu&quot;,&quot;profile_path&quot;:&quot;/users/HotOffTheCouchPotato&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;HotOffTheCouchPotato\&quot; data-tippy-content=\&quot;HotOffTheCouchPotato\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://www.codewars.com/packs/assets/profile-pic.f3a90aca.png\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]}],&quot;allowedLabels&quot;:[],&quot;totalComments&quot;:21,&quot;spoilerFlag&quot;:true,&quot;commentUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/5387b2beee8452489900056a/comments/%7Bcomment_id%7D&quot;,&quot;voteUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/5387b2beee8452489900056a/comments/%7BrefId%7D/vote/%7Bvalue%7D&quot;,&quot;userVotesUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/5387b2beee8452489900056a/comments/user_votes&quot;,&quot;labelGroups&quot;:[{&quot;name&quot;:&quot;Comments&quot;,&quot;label&quot;:null,&quot;count&quot;:16}],&quot;stateGroups&quot;:[{&quot;name&quot;:&quot;Open&quot;,&quot;count&quot;:16}]}" data-view-type="CommentsView" id="comments_list_view" class="js-rendered"><div class="view-placeholder p-15px" style="display: none;">Loading comments...</div><script type="template"><div class="comments" data-bind-data-comment-url="commentUrl" data-bind-data-vote-url="voteUrl"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="5387b2beee8452489900056a"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>195</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>389</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span data-bind-text="totalComments"></span></a></li><li><a href="/kumite/588ba33ab81d9bc28700004b"><i class="icon-moon-forked "></i>2</a></li><li><a href="/kumite/new?group_id=5387b2beee8452489900056a&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li data-bind-if="$solution"><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="/kata/reviews/52bc74d4ac05d0945d000551/groups/5387b2beee8452489900056a">Link</a></li></ul><div class="clearfix"></div><div class="comment-label-filters" data-bind-if="labelGroups | many?"><ul class="piped-text m-4 use-alt-active-color"><li><a class="is-active" data-label="all">All</a></li><li data-bind-each="labelGroups" data-bind-if="@label"><a data-bind-data-label="@label" data-bind-id="label-{{@label}}" data-bind-text="{{@name}} ({{@count}})"></a></li></ul></div><div class="clearfix"></div><ul class="comments-list is-hidden" data-bind-user-votes-url="userVotesUrl"><include data-template="#_comment_new"></include><li class="mt-15px" data-bind-class="hr_class"><hr /></li><include data-bind-each="comments" data-template="#_comment_item"></include></ul></div><div class="clearfix"></div></script><div class="view" data-context="root"><div class="comments" data-vote-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/5387b2beee8452489900056a/comments/%7BrefId%7D/vote/%7Bvalue%7D" data-comment-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/5387b2beee8452489900056a/comments/%7Bcomment_id%7D"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="5387b2beee8452489900056a"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>195</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>389</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span>21</span></a></li><li><a href="https://www.codewars.com/kumite/588ba33ab81d9bc28700004b"><i class="icon-moon-forked "></i>2</a></li><li><a href="https://www.codewars.com/kumite/new?group_id=5387b2beee8452489900056a&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="https://www.codewars.com/kata/reviews/52bc74d4ac05d0945d000551/groups/5387b2beee8452489900056a">Link</a></li></ul><div class="clearfix"></div><div class="clearfix"></div><ul class="comments-list is-hidden" user-votes-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/5387b2beee8452489900056a/comments/user_votes"><li class="new-comment mt-5" data-context-key="x5baaom8ql" data-template-selector="#_comment_new"><figure><a href="https://www.codewars.com/users/zowietao"><img title="zowietao" data-tippy-content="zowietao" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><div class="preedit px-1"><input class="block w-64 rounded-none rounded-md sm:text-sm dark:bg-gray-800 focus:outline-none focus:ring-cgray-300 dark:focus:ring-cgray-600 focus:border-cgray-300 dark:focus:border-cgray-600 border-gray-300 dark:border-gray-700" placeholder="Leave feedback..." type="text"></div><div class="form"><div class="markdown-editor is-compact is-vertical is-low-light"><div class="tabs"><dl class="tabs is-contained is-vertical"><dd class="is-active" data-tippy-content="Edit your message using markdown" data-tippy-placement="top"><a data-tab="markdown"><i class="icon-moon-edit "></i></a></dd><dd data-tippy-content="Preview your comment" data-tippy-placement="right"><a data-tab="preview"><i class="icon-moon-preview "></i></a></dd><dd data-tippy-content="Edit in full-screen mode" data-tippy-placement="bottom"><a class="js-expand"><i class="icon-moon-expand "></i></a></dd></dl><ul class="tabs-content"><li class="is-active" data-tab="markdown"><div class="text-editor-container"><div class="text-editor js-editor has-shadow"><div class="CodeMirror CodeMirror-wrap cm-s-codewars" translate="no"><div style="overflow: hidden; position: relative; width: 3px; height: 0px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; min-height: 1em; outline: none;"></textarea></div><div class="CodeMirror-vscrollbar" tabindex="-1" cm-not-content="true"><div style="min-width: 1px;"></div></div><div class="CodeMirror-hscrollbar" tabindex="-1" cm-not-content="true"><div style="height: 100%; min-height: 1px;"></div></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px;"><div style="position: relative;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre class="CodeMirror-line-like"><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-cursors"></div><div class="CodeMirror-code" role="presentation"></div></div></div></div></div><div style="position: absolute; height: 50px; width: 1px;"></div><div class="CodeMirror-gutters" style="left: 0px;"><div class="CodeMirror-gutter CodeMirror-foldgutter"></div></div></div></div><div class="editor-msg-container is-hidden"><div class="alert-box"></div></div></div><textarea style="display: none;"></textarea></div></li><li data-tab="preview"><div class="panel bg-ui-section is-overflow-auto"><div class="markdown prose max-w-none"><p>Your rendered <a rel="noopener" href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">github-flavored</a> markdown will appear here.</p></div></div></li></ul></div></div><div class="js-spoiler-flag mb-2"><label class="inline-flex items-center"><input class="rounded bg-gray-400 dark:bg-gray-600 border-transparent focus:border-transparent focus:bg-gray-400 text-gray-700 focus:ring-1 focus:ring-offset-2 dark:ring-offset-1 focus:ring-gray-500 dark:focus:ring-gray-700 dark:focus:ring-offset-gray-800" name="eRM" type="checkbox"><span class="ml-1" data-tippy-content="Check this if you are posting content that might give the answer to someone who hasn&#39;t solved the kata yet" data-tippy-placement="top">Mark as having spoiler content</span></label></div><ul class="btns"><li><a class="btn js-post">Post</a></li><li><a class="btn is-link js-cancel">Cancel</a></li></ul></div><div class="clearfix mb-15px"></div></div><div class="clearfix"></div></li><li class="mt-15px"><hr></li><li class="comment" id="60fd016e4c067d000d03e211" data-username="Tom-Hudson" data-state="Open" data-label="no-label" data-context-key="pwzk85euk2" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/Tom-Hudson"><img title="Tom-Hudson" data-tippy-content="Tom-Hudson" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/26221061"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/Tom-Hudson">Tom-Hudson</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#60fd016e4c067d000d03e211"><time-ago lang="en" datetime="2021-07-25T06:15:10.206+0000" title="2021年7月25日 GMT+8 下午2:15">6 months ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="would break for chars like ?"><p>would break for chars like ?</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="60fd016e4c067d000d03e211"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="6016b72d287c520018f7dc2d" data-username="dogma-n" data-state="Open" data-label="no-label" data-context-key="bno0n1s8rg" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/dogma-n"><img title="dogma-n" data-tippy-content="dogma-n" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/73856080"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/dogma-n">dogma-n</a><span class="ml-1">(2 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#6016b72d287c520018f7dc2d"><time-ago lang="en" datetime="2021-01-31T13:57:01.710+0000" title="2021年1月31日 GMT+8 下午9:57">12 months ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="if you use regex to solve 5th kyu probs on here i dont like u"><p>if you use regex to solve 5th kyu probs on here i dont like u</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="6016b72d287c520018f7dc2d"><span class="score">-2</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand 2 Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"><li class="comment" id="61203dcf27e7220007500e80" data-username="farhanaditya" data-state="Open" data-label="no-label" data-context-key="y7der2r609h" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/farhanaditya"><img title="farhanaditya" data-tippy-content="farhanaditya" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/farhanaditya">farhanaditya</a><span class="ml-1">(1 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#61203dcf27e7220007500e80"><time-ago lang="en" datetime="2021-08-20T23:42:07.498+0000" title="2021年8月21日 GMT+8 上午7:42">5 months ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="What&#39;s wrong with Regex? I&#39;d say it&#39;s fine to use whatever method as long as it&#39;s natively build into javascript (not importing a library) and it&#39;s not forbidden by the author."><p>What's wrong with Regex? I'd say it's fine to use whatever method as long as it's natively build into javascript (not importing a library) and it's not forbidden by the author.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="61203dcf27e7220007500e80"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="6122694f01ef9f003f9c810e" data-username="dogma-n" data-state="Open" data-label="no-label" data-context-key="vtqfszooky" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/dogma-n"><img title="dogma-n" data-tippy-content="dogma-n" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/73856080"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/dogma-n">dogma-n</a><span class="ml-1">(2 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#6122694f01ef9f003f9c810e"><time-ago lang="en" datetime="2021-08-22T15:12:15.063+0000" title="2021年8月22日 GMT+8 下午11:12">5 months ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="regex bad"><p>regex bad</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="6122694f01ef9f003f9c810e"><span class="score">0</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li></ul></div></div></li><li class="comment" id="6010a457793857001df172b8" data-username="karaeg-san" data-state="Open" data-label="no-label" data-context-key="t9lg0scyiu" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/karaeg-san"><img title="karaeg-san" data-tippy-content="karaeg-san" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/16840272"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/karaeg-san">karaeg-san</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#6010a457793857001df172b8"><time-ago lang="en" datetime="2021-01-26T23:23:03.465+0000" title="2021年1月27日 GMT+8 上午7:23">12 months ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Excellent solution. I think imperatively, I must spend a year in the temple with the honorable declarative monks."><p>Excellent solution. I think imperatively, I must spend a year in the temple with the honorable declarative monks.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="6010a457793857001df172b8"><span class="score">3</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5f8d90dbf130ea00290f4d26" data-username="smolair0377" data-state="Open" data-label="no-label" data-context-key="wejvcitr7p" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/smolair0377"><img title="smolair0377" data-tippy-content="smolair0377" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/61193297"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/smolair0377">smolair0377</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5f8d90dbf130ea00290f4d26"><time-ago lang="en" datetime="2020-10-19T13:12:59.938+0000" title="2020年10月19日 GMT+8 下午9:12">15 months ago</time-ago></a></li><li class="text-ui-text-lc"><span class="bullet"></span><span>2 edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Very nice !

I wanted to use recursion to solve this. I could have done it using .search() method instead of .match() (don&#39;t know which is better). "><p>Very nice !</p>
<p>I wanted to use recursion to solve this. I could have done it using .search() method instead of .match() (don't know which is better).</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5f8d90dbf130ea00290f4d26"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5f49103c1263340024dc9b8f" data-username="c99.rahul" data-state="Open" data-label="no-label" data-context-key="m2lqfeqzr5a" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/c99.rahul"><img title="c99.rahul" data-tippy-content="c99.rahul" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/c99.rahul">c99.rahul</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5f49103c1263340024dc9b8f"><time-ago lang="en" datetime="2020-08-28T14:10:04.609+0000" title="2020年8月28日 GMT+8 下午10:10">17 months ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Clever, indeed.

I chose a different, slightly longer path counting each character in the string and everything, which is not as cool as this one. Good job."><p>Clever, indeed.</p>
<p>I chose a different, slightly longer path counting each character in the string and everything, which is not as cool as this one. Good job.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5f49103c1263340024dc9b8f"><span class="score">2</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5e62e81a6353a40016afc8d9" data-username="Wolf Fivousix" data-state="Open" data-label="no-label" data-context-key="qv3zlvk7z5n" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/Wolf%20Fivousix"><img title="Wolf Fivousix" data-tippy-content="Wolf Fivousix" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/Wolf%20Fivousix">Wolf Fivousix</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5e62e81a6353a40016afc8d9"><time-ago lang="en" datetime="2020-03-07T00:17:30.359+0000" title="2020年3月7日 GMT+8 上午8:17">2 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="This solution is fine, but at 5 Kyu I think it is important to start considering efficiency and redability. This has polynomial complexity. Look at my solution for a linear complexity solution. Clever, but definitely not a &quot;Best Practice&quot;"><p>This solution is fine, but at 5 Kyu I think it is important to start considering efficiency and redability. This has polynomial complexity. Look at my solution for a linear complexity solution. Clever, but definitely not a "Best Practice"</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5e62e81a6353a40016afc8d9"><span class="score">4</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" flag-masked-by="60638bc3dd3138003116627e" flag-masked="false" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5d9d98be8b0f6c002286c65d" data-username="uksarkar" data-state="Open" data-label="no-label" data-context-key="ah4qqvm8135" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/uksarkar"><img title="uksarkar" data-tippy-content="uksarkar" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/19898129"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/uksarkar">uksarkar</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5d9d98be8b0f6c002286c65d"><time-ago lang="en" datetime="2019-10-09T08:22:22.339+0000" title="2019年10月9日 GMT+8 下午4:22">2 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Good solution but there is more better solution."><p>Good solution but there is more better solution.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5d9d98be8b0f6c002286c65d"><span class="score">2</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5c8ebfd236b59b430dca5c02" data-username="jazzyjackson" data-state="Open" data-label="no-label" data-context-key="xtwr2315loa" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/jazzyjackson"><img title="jazzyjackson" data-tippy-content="jazzyjackson" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/7675670"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/jazzyjackson">jazzyjackson</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5c8ebfd236b59b430dca5c02"><time-ago lang="en" datetime="2019-03-17T21:44:59.702+0000" title="2019年3月18日 GMT+8 上午5:44">3 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Good to know for/in works on strings, but performing regex is iterating over the whole string, so this becomes exponential time complexity."><p>Good to know for/in works on strings, but performing regex is iterating over the whole string, so this becomes exponential time complexity.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5c8ebfd236b59b430dca5c02"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5c360c51fdcefd393e71c703" data-username="juanlet" data-state="Open" data-label="no-label" data-context-key="egqo5j89pir" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/juanlet"><img title="juanlet" data-tippy-content="juanlet" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/12257699"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/juanlet">juanlet</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5c360c51fdcefd393e71c703"><time-ago lang="en" datetime="2019-01-09T14:59:29.171+0000" title="2019年1月9日 GMT+8 下午10:59">3 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="using a Map did it for me...nice solution!"><p>using a Map did it for me...nice solution!</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5c360c51fdcefd393e71c703"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5c303697fc5e550014234770" data-username="Camstew7" data-state="Open" data-label="no-label" data-context-key="upmpsi3x538" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/Camstew7"><img title="Camstew7" data-tippy-content="Camstew7" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/44987487"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/Camstew7">Camstew7</a><span class="ml-1">(4 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5c303697fc5e550014234770"><time-ago lang="en" datetime="2019-01-05T04:46:15.761+0000" title="2019年1月5日 GMT+8 下午12:46">3 years ago</time-ago></a></li><li class="text-ui-text-lc"><span class="bullet"></span><span>1 edit</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="brought this back into the kata and saw that it didnt break for &#39;?&#39; and i have no idea why.

I had to create a conditional to add a \ to special characters in order to pass the test including &#39;?&#39; when creating my solution my solution and on the surface this seems to be doing almost the same thing. Would love to understand how this doesnt create the RegExp: /?/gi which would be invalid.

EDIT: apparently running his solution somehow overwrote mine but it I had created a variable called regSplit which split the string into an array of regexps using .map and then used .match on the string until it returned a result with a length of 1"><p>brought this back into the kata and saw that it didnt break for '?' and i have no idea why.</p>
<p>I had to create a conditional to add a \ to special characters in order to pass the test including '?' when creating my solution my solution and on the surface this seems to be doing almost the same thing. Would love to understand how this doesnt create the RegExp: /?/gi which would be invalid.</p>
<p>EDIT: apparently running his solution somehow overwrote mine but it I had created a variable called regSplit which split the string into an array of regexps using .map and then used .match on the string until it returned a result with a length of 1</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5c303697fc5e550014234770"><span class="score">3</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden is-active"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" flag-masked-by="5bea34f52635539d29000150" flag-masked="true" data-tippy-content="Un-flag this comment as having spoilers within it."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5bebdf4ed415659bb000007d" data-username="trajan" data-state="Open" data-label="no-label" data-context-key="9mukzrvvox" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/trajan"><img title="trajan" data-tippy-content="trajan" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/trajan">trajan</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5bebdf4ed415659bb000007d"><time-ago lang="en" datetime="2018-11-14T08:39:42.772+0000" title="2018年11月14日 GMT+8 下午4:39">3 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Not working with string containing &quot;?&quot; symbol, as in test"><p>Not working with string containing "?" symbol, as in test</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5bebdf4ed415659bb000007d"><span class="score">2</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand 1 Reply</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"><li class="comment" id="5c9cbef644ef464e331acd0c" data-username="slider27276" data-state="Open" data-label="no-label" data-context-key="puw0xu0yppo" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/slider27276"><img title="slider27276" data-tippy-content="slider27276" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/slider27276">slider27276</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5c9cbef644ef464e331acd0c"><time-ago lang="en" datetime="2019-03-28T12:32:56.607+0000" title="2019年3月28日 GMT+8 下午8:32">3 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Yes. Test is completed because &#39;?&#39; after correct symbol :)"><p>Yes. Test is completed because '?' after correct symbol :)</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5c9cbef644ef464e331acd0c"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li></ul></div></div></li><li class="comment" id="5b515302bdd0744820000090" data-username="snydergd" data-state="Open" data-label="no-label" data-context-key="f1mxuh3tj6u" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/snydergd"><img title="snydergd" data-tippy-content="snydergd" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/1040083"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/snydergd">snydergd</a><span class="ml-1">(6 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5b515302bdd0744820000090"><time-ago lang="en" datetime="2018-07-20T03:12:02.962+0000" title="2018年7月20日 GMT+8 上午11:12">4 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Nice easy way to do this if you can solve the problem mentioned for special characters.  &#39;\&#39; will be the hardest character to deal with I think.

One downside to your approach is that it has exponential time complexity, so if you were to have 100,000 characters, worst case would be at least 10,000,000,000 operations, which would be too slow for most situations.

Of course, most of the time you probably won&#39;t deal with input that large.  :)"><p>Nice easy way to do this if you can solve the problem mentioned for special characters.  '' will be the hardest character to deal with I think.</p>
<p>One downside to your approach is that it has exponential time complexity, so if you were to have 100,000 characters, worst case would be at least 10,000,000,000 operations, which would be too slow for most situations.</p>
<p>Of course, most of the time you probably won't deal with input that large.  :)</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5b515302bdd0744820000090"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5a61f19cfd56cb42a200004b" data-username="rejam" data-state="Open" data-label="no-label" data-context-key="f8mivorhon4" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/rejam"><img title="rejam" data-tippy-content="rejam" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/rejam">rejam</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5a61f19cfd56cb42a200004b"><time-ago lang="en" datetime="2018-01-19T13:24:44.712+0000" title="2018年1月19日 GMT+8 下午9:24">4 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="This would break for special characters in the regex because they aren&#39;t escaped.
It only passes all of the tests because, fortunately, it finds a match before it hits the &#39;?&#39;."><p>This would break for special characters in the regex because they aren't escaped.<br>
It only passes all of the tests because, fortunately, it finds a match before it hits the '?'.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5a61f19cfd56cb42a200004b"><span class="score">6</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand 1 Reply</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"><li class="comment" id="5ace8c44830617280d000084" data-username="Wildpat01" data-state="Open" data-label="no-label" data-context-key="quz1eaz3ns" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/Wildpat01"><img title="Wildpat01" data-tippy-content="Wildpat01" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/Wildpat01">Wildpat01</a><span class="ml-1">(4 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5ace8c44830617280d000084"><time-ago lang="en" datetime="2018-04-11T22:29:24.397+0000" title="2018年4月12日 GMT+8 上午6:29">4 years ago</time-ago></a></li><li class="text-ui-text-lc"><span class="bullet"></span><span>1 edit</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Agreed. The new RegExp should go like this:
```
new RegExp( &quot;[&quot; + s[i] + &quot;]&quot;, &quot;gi&quot;)

"><p>Agreed. The new RegExp should go like this:</p>
<pre><code>new RegExp( "[" + s[i] + "]", "gi")

</code></pre></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5ace8c44830617280d000084"><span class="score">7</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" flag-masked="false" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li></ul></div></div></li><li class="comment" id="59274f94356e51500c00006c" data-username="FMurray" data-state="Open" data-label="no-label" data-context-key="n75h24efrfc" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/FMurray"><img title="FMurray" data-tippy-content="FMurray" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/5853331"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/FMurray">FMurray</a><span class="ml-1">(6 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#59274f94356e51500c00006c"><time-ago lang="en" datetime="2017-05-25T21:41:40.217+0000" title="2017年5月26日 GMT+8 上午5:41">5 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="You might be getting lucky here, since there is no guaruntee that for...in will iterate over the characters in order. Am I missing something?"><p>You might be getting lucky here, since there is no guaruntee that for...in will iterate over the characters in order. Am I missing something?</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="59274f94356e51500c00006c"><span class="score">2</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand 1 Reply</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"><li class="comment" id="5935e2d452e1c6392600005f" data-username="KevCJones" data-state="Open" data-label="no-label" data-context-key="da5v75i7o5j" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/KevCJones"><img title="KevCJones" data-tippy-content="KevCJones" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/696048"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/KevCJones">KevCJones</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5935e2d452e1c6392600005f"><time-ago lang="en" datetime="2017-06-05T23:01:40.931+0000" title="2017年6月6日 GMT+8 上午7:01">5 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="As i understood it, iterating is done at the for(var i in s)..could of used a for loop like i did, and then its simply looking for the first character to only match 1."><p>As i understood it, iterating is done at the for(var i in s)..could of used a for loop like i did, and then its simply looking for the first character to only match 1.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5935e2d452e1c6392600005f"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden is-active"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" flag-masked-by="59343229cff4acb1930001ee" flag-masked="true" data-tippy-content="Un-flag this comment as having spoilers within it."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li></ul></div></div></li><li class="comment" id="58c8f378bd1c2471600000f8" data-username="MrZhangFengfeng" data-state="Open" data-label="no-label" data-context-key="od2iwnb755" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/MrZhangFengfeng"><img title="MrZhangFengfeng" data-tippy-content="MrZhangFengfeng" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/24266779"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/MrZhangFengfeng">MrZhangFengfeng</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#58c8f378bd1c2471600000f8"><time-ago lang="en" datetime="2017-03-15T07:55:36.641+0000" title="2017年3月15日 GMT+8 下午3:55">5 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="clever!"><p>clever!</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="58c8f378bd1c2471600000f8"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5798a54839f33ae28300031c" data-username="HotOffTheCouchPotato" data-state="Open" data-label="no-label" data-context-key="50qnygeq3ns" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/HotOffTheCouchPotato"><img title="HotOffTheCouchPotato" data-tippy-content="HotOffTheCouchPotato" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/HotOffTheCouchPotato">HotOffTheCouchPotato</a><span class="ml-1">(3 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5798a54839f33ae28300031c"><time-ago lang="en" datetime="2016-07-27T12:12:56.256+0000" title="2016年7月27日 GMT+8 下午8:12">6 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Didn&#39;t know you could iterate through a string that way. We learn something new everyday! :)

Good job sir!"><p>Didn't know you could iterate through a string that way. We learn something new everyday! :)</p>
<p>Good job sir!</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5798a54839f33ae28300031c"><span class="score">5</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li></ul></div><div class="clearfix"></div></div></view></li><li class="js-result-group pb-30px mb-30px" data-controller="solution-group" data-solution-group-group-id-value="57c841f3484cf97db800024d" data-solution-group-review-id-value="52bc74d4ac05d0945d000551" id="57c841f3484cf97db800024d"><h6><i class="icon-moon-users "></i><a class="font-semibold" href="https://www.codewars.com/users/dragonfire">dragonfire</a><span>, </span><a href="https://www.codewars.com/users/MarcoPolouuu">MarcoPolouuu</a><span>, </span><a href="https://www.codewars.com/users/snaxbags">snaxbags</a><span>, </span><a href="https://www.codewars.com/users/DonMadrone">DonMadrone</a><span>, </span><a href="https://www.codewars.com/users/George_RF">George_RF</a><div class="clearfix"></div></h6><pre class="p-2 overflow-x-auto"><code data-language="javascript"><span class="cm-keyword">function</span> <span class="cm-def">firstNonRepeatingLetter</span>(<span class="cm-def">s</span>) {
  <span class="cm-keyword">var</span> <span class="cm-def">t</span><span class="cm-operator">=</span><span class="cm-variable-2">s</span>.<span class="cm-property">toLowerCase</span>();
  <span class="cm-keyword">for</span> (<span class="cm-keyword">var</span> <span class="cm-def">x</span><span class="cm-operator">=</span><span class="cm-number">0</span>;<span class="cm-variable-2">x</span><span class="cm-operator">&lt;</span><span class="cm-variable-2">t</span>.<span class="cm-property">length</span>;<span class="cm-variable-2">x</span><span class="cm-operator">++</span>)
    <span class="cm-keyword">if</span>(<span class="cm-variable-2">t</span>.<span class="cm-property">indexOf</span>(<span class="cm-variable-2">t</span>[<span class="cm-variable-2">x</span>]) <span class="cm-operator">===</span> <span class="cm-variable-2">t</span>.<span class="cm-property">lastIndexOf</span>(<span class="cm-variable-2">t</span>[<span class="cm-variable-2">x</span>]))
      <span class="cm-keyword">return</span> <span class="cm-variable-2">s</span>[<span class="cm-variable-2">x</span>];
  <span class="cm-keyword">return</span> <span class="cm-string">""</span>;
}</code></pre><div data-controller="solution-variations" data-solution-variations-group-id-value="57c841f3484cf97db800024d" data-solution-variations-review-id-value="52bc74d4ac05d0945d000551"><div class="mt-4 mb-0 px-1 text-ui-text-lc flex justify-between"><div>2 similar code variations are grouped with this one<i class="icon-moon-info ml-1" data-tippy-content="We group similar results by ignoring whitespace, linebreaks and very minor character variations." data-tippy-placement="bottom"></i></div><button class="hidden sm:block" data-action="solution-variations#toggle">Show Variations</button></div><div class="has-top-border mt-4 pt-4 is-hidden space-y-4" data-solution-variations-target="container"></div></div><div class="js-compare is-hidden" data-template="#_compare_solution"></div><div class="clearfix"></div><view data-view-data="{&quot;comments&quot;:[{&quot;id&quot;:&quot;61cca75b9ab67c00262956c0&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;6195e601ec1012451615d92c&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;6195e601ec1012451615d92c&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;This is old, but you could remove the first indexOf t[x], as you already know the index is x.\n&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eThis is old, but you could remove the first indexOf t[x], as you already know the index is x.\u003c/p\u003e&quot;,&quot;created_at&quot;:1640802139,&quot;created_at_datetime&quot;:&quot;2021-12-29T18:22:19.191+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#61cca75b9ab67c00262956c0&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;6195e601ec1012451615d92c&quot;,&quot;username&quot;:&quot;Riscen&quot;,&quot;rank_name&quot;:&quot;6 kyu&quot;,&quot;profile_path&quot;:&quot;/users/Riscen&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;Riscen\&quot; data-tippy-content=\&quot;Riscen\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://www.codewars.com/packs/assets/profile-pic.f3a90aca.png\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5839bac86fe5a162c100006b&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:3,&quot;user_id&quot;:&quot;56253e114a1459ccbd000027&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;56253e114a1459ccbd000027&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;I used to do this a lot in my code too. Only problem is that indexOf and lastIndexOf could loop over the whole array. This runtime could be O(n^3)\n&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eI used to do this a lot in my code too. Only problem is that indexOf and lastIndexOf could loop over the whole array. This runtime could be O(n^3)\u003c/p\u003e&quot;,&quot;created_at&quot;:1480178376,&quot;created_at_datetime&quot;:&quot;2016-11-26T16:39:36.704+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:4,&quot;hash&quot;:&quot;#5839bac86fe5a162c100006b&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;56253e114a1459ccbd000027&quot;,&quot;username&quot;:&quot;skbolton&quot;,&quot;rank_name&quot;:&quot;4 kyu&quot;,&quot;profile_path&quot;:&quot;/users/skbolton&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;skbolton\&quot; data-tippy-content=\&quot;skbolton\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/13260877?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[{&quot;id&quot;:&quot;5a064a7f697598b70e000002&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;57e6c929eae959b9650002a8&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;57e6c929eae959b9650002a8&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;I dunno his benchmarks ~10x faster than yours does.&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eI dunno his benchmarks ~10x faster than yours does.\u003c/p\u003e&quot;,&quot;created_at&quot;:1510361727,&quot;created_at_datetime&quot;:&quot;2017-11-11T00:55:27.613+0000&quot;,&quot;nest_level&quot;:1,&quot;collapsed&quot;:false,&quot;total_comments&quot;:null,&quot;hash&quot;:&quot;#5a064a7f697598b70e000002&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;57e6c929eae959b9650002a8&quot;,&quot;username&quot;:&quot;Firefly2002&quot;,&quot;rank_name&quot;:&quot;2 kyu&quot;,&quot;profile_path&quot;:&quot;/users/Firefly2002&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;Firefly2002\&quot; data-tippy-content=\&quot;Firefly2002\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/21692852?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5a067aa5c9fc0e8e97000050&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:3,&quot;user_id&quot;:&quot;588da1945e86e6660d00004e&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;588da1945e86e6660d00004e&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;This is not O(n^3), the two indexOf are done in parallel.\n\nBy that logic if I do 10 indexOf at once my code would be O(n^11).&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eThis is not O(n^3), the two indexOf are done in parallel.\u003c/p\u003e\n\u003cp\u003eBy that logic if I do 10 indexOf at once my code would be O(n^11).\u003c/p\u003e&quot;,&quot;created_at&quot;:1510374053,&quot;created_at_datetime&quot;:&quot;2017-11-11T04:20:53.234+0000&quot;,&quot;nest_level&quot;:1,&quot;collapsed&quot;:false,&quot;total_comments&quot;:null,&quot;hash&quot;:&quot;#5a067aa5c9fc0e8e97000050&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;588da1945e86e6660d00004e&quot;,&quot;username&quot;:&quot;Voile&quot;,&quot;rank_name&quot;:&quot;2 dan&quot;,&quot;profile_path&quot;:&quot;/users/Voile&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;Voile\&quot; data-tippy-content=\&quot;Voile\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/14909989?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5ccaf6d6d7f0860010ead328&quot;,&quot;masked&quot;:true,&quot;masked_by_id&quot;:&quot;59a36c5e49ae65231e000060&quot;,&quot;votes_score&quot;:0,&quot;user_id&quot;:&quot;59a36c5e49ae65231e000060&quot;,&quot;edit_count&quot;:1,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;59a36c5e49ae65231e000060&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Clever to use the comparison in the for loop like that! Fun to read.\n\nI didn&#39;t think that `indexOf` and `lastIndexOf` calls would be run in parallel by the brwoser. I would like to know where this behavior is documented. I am curious if this is part of the ECMA 2015 spec or left to the browser/Node implementation.\n\nEven in parallel, wouldn&#39;t the time complexity be O(n^2)? Are browsers implementing pre-processing when the string is instantiated to support sorted search algorithms? I had assumed that a two step solution involving a map would be required to perform faster than O(n^2).&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eClever to use the comparison in the for loop like that! Fun to read.\u003c/p\u003e\n\u003cp\u003eI didn&#39;t think that \u003ccode\u003eindexOf\u003c/code\u003e and \u003ccode\u003elastIndexOf\u003c/code\u003e calls would be run in parallel by the brwoser. I would like to know where this behavior is documented. I am curious if this is part of the ECMA 2015 spec or left to the browser/Node implementation.\u003c/p\u003e\n\u003cp\u003eEven in parallel, wouldn&#39;t the time complexity be O(n^2)? Are browsers implementing pre-processing when the string is instantiated to support sorted search algorithms? I had assumed that a two step solution involving a map would be required to perform faster than O(n^2).\u003c/p\u003e&quot;,&quot;created_at&quot;:1556805334,&quot;created_at_datetime&quot;:&quot;2019-05-02T13:55:34.929+0000&quot;,&quot;nest_level&quot;:1,&quot;collapsed&quot;:false,&quot;total_comments&quot;:null,&quot;hash&quot;:&quot;#5ccaf6d6d7f0860010ead328&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;59a36c5e49ae65231e000060&quot;,&quot;username&quot;:&quot;median-man&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/median-man&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;median-man\&quot; data-tippy-content=\&quot;median-man\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/8689789?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5ccaf8ba078ad0000c5a4628&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:5,&quot;user_id&quot;:&quot;588da1945e86e6660d00004e&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;588da1945e86e6660d00004e&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Yes, it&#39;s O(n^2). No, you&#39;re thinking too much and in fact that&#39;s just total nonsense. It holds true even in psuedo-code form.&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eYes, it&#39;s O(n^2). No, you&#39;re thinking too much and in fact that&#39;s just total nonsense. It holds true even in psuedo-code form.\u003c/p\u003e&quot;,&quot;created_at&quot;:1556805818,&quot;created_at_datetime&quot;:&quot;2019-05-02T14:03:38.952+0000&quot;,&quot;nest_level&quot;:1,&quot;collapsed&quot;:false,&quot;total_comments&quot;:null,&quot;hash&quot;:&quot;#5ccaf8ba078ad0000c5a4628&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;588da1945e86e6660d00004e&quot;,&quot;username&quot;:&quot;Voile&quot;,&quot;rank_name&quot;:&quot;2 dan&quot;,&quot;profile_path&quot;:&quot;/users/Voile&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;Voile\&quot; data-tippy-content=\&quot;Voile\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/14909989?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]}]},{&quot;id&quot;:&quot;58198b451f2728cf29000008&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;5811b507acdf4dab5e00028f&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5811b507acdf4dab5e00028f&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;we think like the same way &quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003ewe think like the same way\u003c/p\u003e&quot;,&quot;created_at&quot;:1478069061,&quot;created_at_datetime&quot;:&quot;2016-11-02T06:44:21.675+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#58198b451f2728cf29000008&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5811b507acdf4dab5e00028f&quot;,&quot;username&quot;:&quot;lilng&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/lilng&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;lilng\&quot; data-tippy-content=\&quot;lilng\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://www.codewars.com/packs/assets/profile-pic.f3a90aca.png\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]}],&quot;allowedLabels&quot;:[],&quot;totalComments&quot;:7,&quot;spoilerFlag&quot;:true,&quot;commentUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/57c841f3484cf97db800024d/comments/%7Bcomment_id%7D&quot;,&quot;voteUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/57c841f3484cf97db800024d/comments/%7BrefId%7D/vote/%7Bvalue%7D&quot;,&quot;userVotesUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/57c841f3484cf97db800024d/comments/user_votes&quot;,&quot;labelGroups&quot;:[{&quot;name&quot;:&quot;Comments&quot;,&quot;label&quot;:null,&quot;count&quot;:3}],&quot;stateGroups&quot;:[{&quot;name&quot;:&quot;Open&quot;,&quot;count&quot;:3}]}" data-view-type="CommentsView" id="comments_list_view" class="js-rendered"><div class="view-placeholder p-15px" style="display: none;">Loading comments...</div><script type="template"><div class="comments" data-bind-data-comment-url="commentUrl" data-bind-data-vote-url="voteUrl"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="57c841f3484cf97db800024d"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>118</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>192</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span data-bind-text="totalComments"></span></a></li><li><a href="/kumite/new?group_id=57c841f3484cf97db800024d&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li data-bind-if="$solution"><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="/kata/reviews/52bc74d4ac05d0945d000551/groups/57c841f3484cf97db800024d">Link</a></li></ul><div class="clearfix"></div><div class="comment-label-filters" data-bind-if="labelGroups | many?"><ul class="piped-text m-4 use-alt-active-color"><li><a class="is-active" data-label="all">All</a></li><li data-bind-each="labelGroups" data-bind-if="@label"><a data-bind-data-label="@label" data-bind-id="label-{{@label}}" data-bind-text="{{@name}} ({{@count}})"></a></li></ul></div><div class="clearfix"></div><ul class="comments-list is-hidden" data-bind-user-votes-url="userVotesUrl"><include data-template="#_comment_new"></include><li class="mt-15px" data-bind-class="hr_class"><hr /></li><include data-bind-each="comments" data-template="#_comment_item"></include></ul></div><div class="clearfix"></div></script><div class="view" data-context="root"><div class="comments" data-vote-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/57c841f3484cf97db800024d/comments/%7BrefId%7D/vote/%7Bvalue%7D" data-comment-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/57c841f3484cf97db800024d/comments/%7Bcomment_id%7D"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="57c841f3484cf97db800024d"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>118</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>192</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span>7</span></a></li><li><a href="https://www.codewars.com/kumite/new?group_id=57c841f3484cf97db800024d&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="https://www.codewars.com/kata/reviews/52bc74d4ac05d0945d000551/groups/57c841f3484cf97db800024d">Link</a></li></ul><div class="clearfix"></div><div class="clearfix"></div><ul class="comments-list is-hidden" user-votes-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/57c841f3484cf97db800024d/comments/user_votes"><li class="new-comment mt-5" data-context-key="4ms6xnpo3pr" data-template-selector="#_comment_new"><figure><a href="https://www.codewars.com/users/zowietao"><img title="zowietao" data-tippy-content="zowietao" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><div class="preedit px-1"><input class="block w-64 rounded-none rounded-md sm:text-sm dark:bg-gray-800 focus:outline-none focus:ring-cgray-300 dark:focus:ring-cgray-600 focus:border-cgray-300 dark:focus:border-cgray-600 border-gray-300 dark:border-gray-700" placeholder="Leave feedback..." type="text"></div><div class="form"><div class="markdown-editor is-compact is-vertical is-low-light"><div class="tabs"><dl class="tabs is-contained is-vertical"><dd class="is-active" data-tippy-content="Edit your message using markdown" data-tippy-placement="top"><a data-tab="markdown"><i class="icon-moon-edit "></i></a></dd><dd data-tippy-content="Preview your comment" data-tippy-placement="right"><a data-tab="preview"><i class="icon-moon-preview "></i></a></dd><dd data-tippy-content="Edit in full-screen mode" data-tippy-placement="bottom"><a class="js-expand"><i class="icon-moon-expand "></i></a></dd></dl><ul class="tabs-content"><li class="is-active" data-tab="markdown"><div class="text-editor-container"><div class="text-editor js-editor has-shadow"><div class="CodeMirror CodeMirror-wrap cm-s-codewars" translate="no"><div style="overflow: hidden; position: relative; width: 3px; height: 0px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; min-height: 1em; outline: none;"></textarea></div><div class="CodeMirror-vscrollbar" tabindex="-1" cm-not-content="true"><div style="min-width: 1px;"></div></div><div class="CodeMirror-hscrollbar" tabindex="-1" cm-not-content="true"><div style="height: 100%; min-height: 1px;"></div></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px;"><div style="position: relative;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre class="CodeMirror-line-like"><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-cursors"></div><div class="CodeMirror-code" role="presentation"></div></div></div></div></div><div style="position: absolute; height: 50px; width: 1px;"></div><div class="CodeMirror-gutters" style="left: 0px;"><div class="CodeMirror-gutter CodeMirror-foldgutter"></div></div></div></div><div class="editor-msg-container is-hidden"><div class="alert-box"></div></div></div><textarea style="display: none;"></textarea></div></li><li data-tab="preview"><div class="panel bg-ui-section is-overflow-auto"><div class="markdown prose max-w-none"><p>Your rendered <a rel="noopener" href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">github-flavored</a> markdown will appear here.</p></div></div></li></ul></div></div><div class="js-spoiler-flag mb-2"><label class="inline-flex items-center"><input class="rounded bg-gray-400 dark:bg-gray-600 border-transparent focus:border-transparent focus:bg-gray-400 text-gray-700 focus:ring-1 focus:ring-offset-2 dark:ring-offset-1 focus:ring-gray-500 dark:focus:ring-gray-700 dark:focus:ring-offset-gray-800" name="eRM" type="checkbox"><span class="ml-1" data-tippy-content="Check this if you are posting content that might give the answer to someone who hasn&#39;t solved the kata yet" data-tippy-placement="top">Mark as having spoiler content</span></label></div><ul class="btns"><li><a class="btn js-post">Post</a></li><li><a class="btn is-link js-cancel">Cancel</a></li></ul></div><div class="clearfix mb-15px"></div></div><div class="clearfix"></div></li><li class="mt-15px"><hr></li><li class="comment" id="61cca75b9ab67c00262956c0" data-username="Riscen" data-state="Open" data-label="no-label" data-context-key="h9ojprz104n" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/Riscen"><img title="Riscen" data-tippy-content="Riscen" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/Riscen">Riscen</a><span class="ml-1">(6 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#61cca75b9ab67c00262956c0"><time-ago lang="en" datetime="2021-12-29T18:22:19.191+0000" title="2021年12月30日 GMT+8 上午2:22">28 days ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="This is old, but you could remove the first indexOf t[x], as you already know the index is x.
"><p>This is old, but you could remove the first indexOf t[x], as you already know the index is x.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="61cca75b9ab67c00262956c0"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5839bac86fe5a162c100006b" data-username="skbolton" data-state="Open" data-label="no-label" data-context-key="efui4fafn8f" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/skbolton"><img title="skbolton" data-tippy-content="skbolton" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/13260877"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/skbolton">skbolton</a><span class="ml-1">(4 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5839bac86fe5a162c100006b"><time-ago lang="en" datetime="2016-11-26T16:39:36.704+0000" title="2016年11月27日 GMT+8 上午12:39">5 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="I used to do this a lot in my code too. Only problem is that indexOf and lastIndexOf could loop over the whole array. This runtime could be O(n^3)
"><p>I used to do this a lot in my code too. Only problem is that indexOf and lastIndexOf could loop over the whole array. This runtime could be O(n^3)</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5839bac86fe5a162c100006b"><span class="score">3</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand 4 Replies</span></a></li><li><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments"><ul class="comments-list"><li class="comment" id="5a064a7f697598b70e000002" data-username="Firefly2002" data-state="Open" data-label="no-label" data-context-key="pnp5j296mob" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/Firefly2002"><img title="Firefly2002" data-tippy-content="Firefly2002" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/21692852"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/Firefly2002">Firefly2002</a><span class="ml-1">(2 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5a064a7f697598b70e000002"><time-ago lang="en" datetime="2017-11-11T00:55:27.613+0000" title="2017年11月11日 GMT+8 上午8:55">4 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="I dunno his benchmarks ~10x faster than yours does."><p>I dunno his benchmarks ~10x faster than yours does.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5a064a7f697598b70e000002"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5a067aa5c9fc0e8e97000050" data-username="Voile" data-state="Open" data-label="no-label" data-context-key="b6e543fj41w" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/Voile"><img title="Voile" data-tippy-content="Voile" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/14909989"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/Voile">Voile</a><span class="ml-1">(2 dan)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5a067aa5c9fc0e8e97000050"><time-ago lang="en" datetime="2017-11-11T04:20:53.234+0000" title="2017年11月11日 GMT+8 下午12:20">4 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="This is not O(n^3), the two indexOf are done in parallel.

By that logic if I do 10 indexOf at once my code would be O(n^11)."><p>This is not O(n^3), the two indexOf are done in parallel.</p>
<p>By that logic if I do 10 indexOf at once my code would be O(n^11).</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5a067aa5c9fc0e8e97000050"><span class="score">3</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5ccaf6d6d7f0860010ead328" data-username="median-man" data-state="Open" data-label="no-label" data-context-key="uvxikgdy4yj" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/median-man"><img title="median-man" data-tippy-content="median-man" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/8689789"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/median-man">median-man</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5ccaf6d6d7f0860010ead328"><time-ago lang="en" datetime="2019-05-02T13:55:34.929+0000" title="2019年5月2日 GMT+8 下午9:55">3 years ago</time-ago></a></li><li class="text-ui-text-lc"><span class="bullet"></span><span>1 edit</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Clever to use the comparison in the for loop like that! Fun to read.

I didn&#39;t think that `indexOf` and `lastIndexOf` calls would be run in parallel by the brwoser. I would like to know where this behavior is documented. I am curious if this is part of the ECMA 2015 spec or left to the browser/Node implementation.

Even in parallel, wouldn&#39;t the time complexity be O(n^2)? Are browsers implementing pre-processing when the string is instantiated to support sorted search algorithms? I had assumed that a two step solution involving a map would be required to perform faster than O(n^2)."><p>Clever to use the comparison in the for loop like that! Fun to read.</p>
<p>I didn't think that <code>indexOf</code> and <code>lastIndexOf</code> calls would be run in parallel by the brwoser. I would like to know where this behavior is documented. I am curious if this is part of the ECMA 2015 spec or left to the browser/Node implementation.</p>
<p>Even in parallel, wouldn't the time complexity be O(n^2)? Are browsers implementing pre-processing when the string is instantiated to support sorted search algorithms? I had assumed that a two step solution involving a map would be required to perform faster than O(n^2).</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5ccaf6d6d7f0860010ead328"><span class="score">0</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden is-active"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" flag-masked-by="59a36c5e49ae65231e000060" flag-masked="true" data-tippy-content="Un-flag this comment as having spoilers within it."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5ccaf8ba078ad0000c5a4628" data-username="Voile" data-state="Open" data-label="no-label" data-context-key="6a6t65xskvo" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/Voile"><img title="Voile" data-tippy-content="Voile" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/14909989"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/Voile">Voile</a><span class="ml-1">(2 dan)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5ccaf8ba078ad0000c5a4628"><time-ago lang="en" datetime="2019-05-02T14:03:38.952+0000" title="2019年5月2日 GMT+8 下午10:03">3 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Yes, it&#39;s O(n^2). No, you&#39;re thinking too much and in fact that&#39;s just total nonsense. It holds true even in psuedo-code form."><p>Yes, it's O(n^2). No, you're thinking too much and in fact that's just total nonsense. It holds true even in psuedo-code form.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5ccaf8ba078ad0000c5a4628"><span class="score">5</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li></ul></div><ul class="js-actions-bar comment-actions is-auto-hidden bulleted-text"><li><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li></ul></div></li><li class="comment" id="58198b451f2728cf29000008" data-username="lilng" data-state="Open" data-label="no-label" data-context-key="0ijbhip5cga" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/lilng"><img title="lilng" data-tippy-content="lilng" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/lilng">lilng</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#58198b451f2728cf29000008"><time-ago lang="en" datetime="2016-11-02T06:44:21.675+0000" title="2016年11月2日 GMT+8 下午2:44">5 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="we think like the same way "><p>we think like the same way</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="58198b451f2728cf29000008"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li></ul></div><div class="clearfix"></div></div></view></li><li class="js-result-group pb-30px mb-30px" data-controller="solution-group" data-solution-group-group-id-value="5b06fc2b7af434d4ba00174b" data-solution-group-review-id-value="52bc74d4ac05d0945d000551" id="5b06fc2b7af434d4ba00174b"><h6><i class="icon-moon-user "></i><a class="font-semibold" href="https://www.codewars.com/users/Niakris">Niakris</a><div class="clearfix"></div></h6><pre class="p-2 overflow-x-auto"><code data-language="javascript"><span class="cm-keyword">function</span> <span class="cm-def">firstNonRepeatingLetter</span>(<span class="cm-def">str</span>){
  <span class="cm-keyword">return</span> <span class="cm-variable-2">str</span>.<span class="cm-property">split</span>(<span class="cm-string">''</span>).<span class="cm-property">find</span>(<span class="cm-def">e</span> <span class="cm-operator">=&gt;</span> <span class="cm-variable-2">str</span>.<span class="cm-property">match</span>(<span class="cm-keyword">new</span> <span class="cm-variable">RegExp</span>(<span class="cm-string-2">`${</span><span class="cm-variable-2">e</span><span class="cm-string-2">}</span><span class="cm-string-2">`</span>, <span class="cm-string">'gi'</span>)).<span class="cm-property">length</span> <span class="cm-operator">===</span> <span class="cm-number">1</span>) <span class="cm-operator">||</span> <span class="cm-string">''</span>
}</code></pre><div class="js-compare is-hidden" data-template="#_compare_solution"></div><div class="clearfix"></div><view data-view-data="{&quot;comments&quot;:[{&quot;id&quot;:&quot;616775fa6814de003e89a7dd&quot;,&quot;masked&quot;:true,&quot;masked_by_id&quot;:&quot;6166296af43455005605b3c5&quot;,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;6166296af43455005605b3c5&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;6166296af43455005605b3c5&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Ideally,\n\nconst firstNonRepeatingLetter = (str) =\u003e str.split(&#39;&#39;).find(e =\u003e str.match(new RegExp(`${e}`, &#39;gi&#39;)).length === 1) || &#39;&#39;;\n\nright?&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eIdeally,\u003c/p\u003e\n\u003cp\u003econst firstNonRepeatingLetter = (str) =\u0026gt; str.split(&#39;&#39;).find(e =\u0026gt; str.match(new RegExp(\u003ccode\u003e${e}\u003c/code\u003e, &#39;gi&#39;)).length === 1) || &#39;&#39;;\u003c/p\u003e\n\u003cp\u003eright?\u003c/p\u003e&quot;,&quot;created_at&quot;:1634170362,&quot;created_at_datetime&quot;:&quot;2021-10-14T00:12:42.864+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#616775fa6814de003e89a7dd&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;6166296af43455005605b3c5&quot;,&quot;username&quot;:&quot;GustavoSmith&quot;,&quot;rank_name&quot;:&quot;6 kyu&quot;,&quot;profile_path&quot;:&quot;/users/GustavoSmith&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;GustavoSmith\&quot; data-tippy-content=\&quot;GustavoSmith\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/51140828?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5bebdf1b0632918ec900009d&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:2,&quot;user_id&quot;:&quot;5bd803ebb0eb75748c0003a1&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5bd803ebb0eb75748c0003a1&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Not working with string containing \&quot;?\&quot;&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eNot working with string containing \&quot;?\&quot;\u003c/p\u003e&quot;,&quot;created_at&quot;:1542184731,&quot;created_at_datetime&quot;:&quot;2018-11-14T08:38:51.736+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#5bebdf1b0632918ec900009d&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5bd803ebb0eb75748c0003a1&quot;,&quot;username&quot;:&quot;trajan&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/trajan&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;trajan\&quot; data-tippy-content=\&quot;trajan\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://www.codewars.com/packs/assets/profile-pic.f3a90aca.png\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]}],&quot;allowedLabels&quot;:[],&quot;totalComments&quot;:2,&quot;spoilerFlag&quot;:true,&quot;commentUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/5b06fc2b7af434d4ba00174b/comments/%7Bcomment_id%7D&quot;,&quot;voteUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/5b06fc2b7af434d4ba00174b/comments/%7BrefId%7D/vote/%7Bvalue%7D&quot;,&quot;userVotesUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/5b06fc2b7af434d4ba00174b/comments/user_votes&quot;,&quot;labelGroups&quot;:[{&quot;name&quot;:&quot;Comments&quot;,&quot;label&quot;:null,&quot;count&quot;:2}],&quot;stateGroups&quot;:[{&quot;name&quot;:&quot;Open&quot;,&quot;count&quot;:2}]}" data-view-type="CommentsView" id="comments_list_view" class="js-rendered"><div class="view-placeholder p-15px" style="display: none;">Loading comments...</div><script type="template"><div class="comments" data-bind-data-comment-url="commentUrl" data-bind-data-vote-url="voteUrl"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="5b06fc2b7af434d4ba00174b"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>27</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>47</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span data-bind-text="totalComments"></span></a></li><li><a href="/kumite/new?group_id=5b06fc2b7af434d4ba00174b&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li data-bind-if="$solution"><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="/kata/reviews/52bc74d4ac05d0945d000551/groups/5b06fc2b7af434d4ba00174b">Link</a></li></ul><div class="clearfix"></div><div class="comment-label-filters" data-bind-if="labelGroups | many?"><ul class="piped-text m-4 use-alt-active-color"><li><a class="is-active" data-label="all">All</a></li><li data-bind-each="labelGroups" data-bind-if="@label"><a data-bind-data-label="@label" data-bind-id="label-{{@label}}" data-bind-text="{{@name}} ({{@count}})"></a></li></ul></div><div class="clearfix"></div><ul class="comments-list is-hidden" data-bind-user-votes-url="userVotesUrl"><include data-template="#_comment_new"></include><li class="mt-15px" data-bind-class="hr_class"><hr /></li><include data-bind-each="comments" data-template="#_comment_item"></include></ul></div><div class="clearfix"></div></script><div class="view" data-context="root"><div class="comments" data-vote-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/5b06fc2b7af434d4ba00174b/comments/%7BrefId%7D/vote/%7Bvalue%7D" data-comment-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/5b06fc2b7af434d4ba00174b/comments/%7Bcomment_id%7D"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="5b06fc2b7af434d4ba00174b"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>27</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>47</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span>2</span></a></li><li><a href="https://www.codewars.com/kumite/new?group_id=5b06fc2b7af434d4ba00174b&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="https://www.codewars.com/kata/reviews/52bc74d4ac05d0945d000551/groups/5b06fc2b7af434d4ba00174b">Link</a></li></ul><div class="clearfix"></div><div class="clearfix"></div><ul class="comments-list is-hidden" user-votes-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/5b06fc2b7af434d4ba00174b/comments/user_votes"><li class="new-comment mt-5" data-context-key="h9wjykoxqgp" data-template-selector="#_comment_new"><figure><a href="https://www.codewars.com/users/zowietao"><img title="zowietao" data-tippy-content="zowietao" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><div class="preedit px-1"><input class="block w-64 rounded-none rounded-md sm:text-sm dark:bg-gray-800 focus:outline-none focus:ring-cgray-300 dark:focus:ring-cgray-600 focus:border-cgray-300 dark:focus:border-cgray-600 border-gray-300 dark:border-gray-700" placeholder="Leave feedback..." type="text"></div><div class="form"><div class="markdown-editor is-compact is-vertical is-low-light"><div class="tabs"><dl class="tabs is-contained is-vertical"><dd class="is-active" data-tippy-content="Edit your message using markdown" data-tippy-placement="top"><a data-tab="markdown"><i class="icon-moon-edit "></i></a></dd><dd data-tippy-content="Preview your comment" data-tippy-placement="right"><a data-tab="preview"><i class="icon-moon-preview "></i></a></dd><dd data-tippy-content="Edit in full-screen mode" data-tippy-placement="bottom"><a class="js-expand"><i class="icon-moon-expand "></i></a></dd></dl><ul class="tabs-content"><li class="is-active" data-tab="markdown"><div class="text-editor-container"><div class="text-editor js-editor has-shadow"><div class="CodeMirror CodeMirror-wrap cm-s-codewars" translate="no"><div style="overflow: hidden; position: relative; width: 3px; height: 0px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; min-height: 1em; outline: none;"></textarea></div><div class="CodeMirror-vscrollbar" tabindex="-1" cm-not-content="true"><div style="min-width: 1px;"></div></div><div class="CodeMirror-hscrollbar" tabindex="-1" cm-not-content="true"><div style="height: 100%; min-height: 1px;"></div></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px;"><div style="position: relative;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre class="CodeMirror-line-like"><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-cursors"></div><div class="CodeMirror-code" role="presentation"></div></div></div></div></div><div style="position: absolute; height: 50px; width: 1px;"></div><div class="CodeMirror-gutters" style="left: 0px;"><div class="CodeMirror-gutter CodeMirror-foldgutter"></div></div></div></div><div class="editor-msg-container is-hidden"><div class="alert-box"></div></div></div><textarea style="display: none;"></textarea></div></li><li data-tab="preview"><div class="panel bg-ui-section is-overflow-auto"><div class="markdown prose max-w-none"><p>Your rendered <a rel="noopener" href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">github-flavored</a> markdown will appear here.</p></div></div></li></ul></div></div><div class="js-spoiler-flag mb-2"><label class="inline-flex items-center"><input class="rounded bg-gray-400 dark:bg-gray-600 border-transparent focus:border-transparent focus:bg-gray-400 text-gray-700 focus:ring-1 focus:ring-offset-2 dark:ring-offset-1 focus:ring-gray-500 dark:focus:ring-gray-700 dark:focus:ring-offset-gray-800" name="eRM" type="checkbox"><span class="ml-1" data-tippy-content="Check this if you are posting content that might give the answer to someone who hasn&#39;t solved the kata yet" data-tippy-placement="top">Mark as having spoiler content</span></label></div><ul class="btns"><li><a class="btn js-post">Post</a></li><li><a class="btn is-link js-cancel">Cancel</a></li></ul></div><div class="clearfix mb-15px"></div></div><div class="clearfix"></div></li><li class="mt-15px"><hr></li><li class="comment" id="616775fa6814de003e89a7dd" data-username="GustavoSmith" data-state="Open" data-label="no-label" data-context-key="eayzivr0zj" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/GustavoSmith"><img title="GustavoSmith" data-tippy-content="GustavoSmith" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/51140828"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/GustavoSmith">GustavoSmith</a><span class="ml-1">(6 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#616775fa6814de003e89a7dd"><time-ago lang="en" datetime="2021-10-14T00:12:42.864+0000" title="2021年10月14日 GMT+8 上午8:12">4 months ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Ideally,

const firstNonRepeatingLetter = (str) =&gt; str.split(&#39;&#39;).find(e =&gt; str.match(new RegExp(`${e}`, &#39;gi&#39;)).length === 1) || &#39;&#39;;

right?"><p>Ideally,</p>
<p>const firstNonRepeatingLetter = (str) =&gt; str.split('').find(e =&gt; str.match(new RegExp(<code>${e}</code>, 'gi')).length === 1) || '';</p>
<p>right?</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="616775fa6814de003e89a7dd"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden is-active"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" flag-masked-by="6166296af43455005605b3c5" flag-masked="true" data-tippy-content="Un-flag this comment as having spoilers within it."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5bebdf1b0632918ec900009d" data-username="trajan" data-state="Open" data-label="no-label" data-context-key="yomxr1bfok" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/trajan"><img title="trajan" data-tippy-content="trajan" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/trajan">trajan</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5bebdf1b0632918ec900009d"><time-ago lang="en" datetime="2018-11-14T08:38:51.736+0000" title="2018年11月14日 GMT+8 下午4:38">3 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Not working with string containing &quot;?&quot;"><p>Not working with string containing "?"</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5bebdf1b0632918ec900009d"><span class="score">2</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li></ul></div><div class="clearfix"></div></div></view></li><li class="js-result-group pb-30px mb-30px" data-controller="solution-group" data-solution-group-group-id-value="581e550f4ffc4e604e00037d" data-solution-group-review-id-value="52bc74d4ac05d0945d000551" id="581e550f4ffc4e604e00037d"><h6><i class="icon-moon-users "></i><a class="font-semibold" href="https://www.codewars.com/users/KaraM">KaraM</a><span>, </span><a href="https://www.codewars.com/users/AP90">AP90</a><span>, </span><a href="https://www.codewars.com/users/ke1echi">ke1echi</a><span>, </span><a href="https://www.codewars.com/users/StasKu">StasKu</a><span>, </span><a href="https://www.codewars.com/users/slee20">slee20</a><span>, </span><a href="https://www.codewars.com/users/jd123_123">jd123_123</a><span>, </span><a href="https://www.codewars.com/users/ozubergz">ozubergz</a><span>, </span><a href="https://www.codewars.com/users/alewis">alewis</a><span>, </span><a href="https://www.codewars.com/users/maximdave">maximdave</a><span>, </span><a href="https://www.codewars.com/users/danny.why">danny.why</a><span>, </span><a href="https://www.codewars.com/users/Artem1991">Artem1991</a><span> (plus 6 more warriors)</span><div class="clearfix"></div></h6><pre class="p-2 overflow-x-auto"><code data-language="javascript"><span class="cm-keyword">function</span> <span class="cm-def">firstNonRepeatingLetter</span>(<span class="cm-def">s</span>) {
  <span class="cm-keyword">let</span> <span class="cm-def">str</span> <span class="cm-operator">=</span> <span class="cm-variable-2">s</span>.<span class="cm-property">toLowerCase</span>();
  <span class="cm-keyword">for</span>(<span class="cm-keyword">let</span> <span class="cm-def">i</span> <span class="cm-operator">=</span> <span class="cm-number">0</span>; <span class="cm-variable-2">i</span> <span class="cm-operator">&lt;</span> <span class="cm-variable-2">str</span>.<span class="cm-property">length</span>; <span class="cm-variable-2">i</span><span class="cm-operator">++</span>) {
    <span class="cm-keyword">if</span>(<span class="cm-variable-2">str</span>.<span class="cm-property">indexOf</span>(<span class="cm-variable-2">str</span>[<span class="cm-variable-2">i</span>]) <span class="cm-operator">===</span> <span class="cm-variable-2">str</span>.<span class="cm-property">lastIndexOf</span>(<span class="cm-variable-2">str</span>[<span class="cm-variable-2">i</span>])) {
      <span class="cm-keyword">return</span> <span class="cm-variable-2">s</span>[<span class="cm-variable-2">i</span>];
    }
  }
  <span class="cm-keyword">return</span> <span class="cm-string">""</span>;
}</code></pre><div data-controller="solution-variations" data-solution-variations-group-id-value="581e550f4ffc4e604e00037d" data-solution-variations-review-id-value="52bc74d4ac05d0945d000551"><div class="mt-4 mb-0 px-1 text-ui-text-lc flex justify-between"><div>15 similar code variations are grouped with this one<i class="icon-moon-info ml-1" data-tippy-content="We group similar results by ignoring whitespace, linebreaks and very minor character variations." data-tippy-placement="bottom"></i></div><button class="hidden sm:block" data-action="solution-variations#toggle">Show Variations</button></div><div class="has-top-border mt-4 pt-4 is-hidden space-y-4" data-solution-variations-target="container"></div></div><div class="js-compare is-hidden" data-template="#_compare_solution"></div><div class="clearfix"></div><view data-view-data="{&quot;comments&quot;:[{&quot;id&quot;:&quot;602abb232463d3001c937245&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:2,&quot;user_id&quot;:&quot;5ce9c05b07d4b70011cbed58&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5ce9c05b07d4b70011cbed58&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Now, that&#39;s clever!&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eNow, that&#39;s clever!\u003c/p\u003e&quot;,&quot;created_at&quot;:1613413155,&quot;created_at_datetime&quot;:&quot;2021-02-15T18:19:15.425+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#602abb232463d3001c937245&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5ce9c05b07d4b70011cbed58&quot;,&quot;username&quot;:&quot;OldestJunior&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/OldestJunior&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;OldestJunior\&quot; data-tippy-content=\&quot;OldestJunior\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/47007157?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5ec4b0411dbe7e0012c6f9a2&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:3,&quot;user_id&quot;:&quot;5ea8b96614d1dc001ffca821&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5ea8b96614d1dc001ffca821&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;This solution is absolutely gorgeous and really easy to read. This is a professional solution to this problem.&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eThis solution is absolutely gorgeous and really easy to read. This is a professional solution to this problem.\u003c/p\u003e&quot;,&quot;created_at&quot;:1589948481,&quot;created_at_datetime&quot;:&quot;2020-05-20T04:21:21.883+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#5ec4b0411dbe7e0012c6f9a2&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5ea8b96614d1dc001ffca821&quot;,&quot;username&quot;:&quot;Colby721&quot;,&quot;rank_name&quot;:&quot;6 kyu&quot;,&quot;profile_path&quot;:&quot;/users/Colby721&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;Colby721\&quot; data-tippy-content=\&quot;Colby721\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://www.codewars.com/packs/assets/profile-pic.f3a90aca.png\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]}],&quot;allowedLabels&quot;:[],&quot;totalComments&quot;:2,&quot;spoilerFlag&quot;:true,&quot;commentUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/581e550f4ffc4e604e00037d/comments/%7Bcomment_id%7D&quot;,&quot;voteUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/581e550f4ffc4e604e00037d/comments/%7BrefId%7D/vote/%7Bvalue%7D&quot;,&quot;userVotesUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/581e550f4ffc4e604e00037d/comments/user_votes&quot;,&quot;labelGroups&quot;:[{&quot;name&quot;:&quot;Comments&quot;,&quot;label&quot;:null,&quot;count&quot;:2}],&quot;stateGroups&quot;:[{&quot;name&quot;:&quot;Open&quot;,&quot;count&quot;:2}]}" data-view-type="CommentsView" id="comments_list_view" class="js-rendered"><div class="view-placeholder p-15px" style="display: none;">Loading comments...</div><script type="template"><div class="comments" data-bind-data-comment-url="commentUrl" data-bind-data-vote-url="voteUrl"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="581e550f4ffc4e604e00037d"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>25</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>8</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span data-bind-text="totalComments"></span></a></li><li><a href="/kumite/new?group_id=581e550f4ffc4e604e00037d&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li data-bind-if="$solution"><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="/kata/reviews/52bc74d4ac05d0945d000551/groups/581e550f4ffc4e604e00037d">Link</a></li></ul><div class="clearfix"></div><div class="comment-label-filters" data-bind-if="labelGroups | many?"><ul class="piped-text m-4 use-alt-active-color"><li><a class="is-active" data-label="all">All</a></li><li data-bind-each="labelGroups" data-bind-if="@label"><a data-bind-data-label="@label" data-bind-id="label-{{@label}}" data-bind-text="{{@name}} ({{@count}})"></a></li></ul></div><div class="clearfix"></div><ul class="comments-list is-hidden" data-bind-user-votes-url="userVotesUrl"><include data-template="#_comment_new"></include><li class="mt-15px" data-bind-class="hr_class"><hr /></li><include data-bind-each="comments" data-template="#_comment_item"></include></ul></div><div class="clearfix"></div></script><div class="view" data-context="root"><div class="comments" data-vote-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/581e550f4ffc4e604e00037d/comments/%7BrefId%7D/vote/%7Bvalue%7D" data-comment-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/581e550f4ffc4e604e00037d/comments/%7Bcomment_id%7D"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="581e550f4ffc4e604e00037d"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>25</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>8</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span>2</span></a></li><li><a href="https://www.codewars.com/kumite/new?group_id=581e550f4ffc4e604e00037d&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="https://www.codewars.com/kata/reviews/52bc74d4ac05d0945d000551/groups/581e550f4ffc4e604e00037d">Link</a></li></ul><div class="clearfix"></div><div class="clearfix"></div><ul class="comments-list is-hidden" user-votes-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/581e550f4ffc4e604e00037d/comments/user_votes"><li class="new-comment mt-5" data-context-key="flwqkq1xq3t" data-template-selector="#_comment_new"><figure><a href="https://www.codewars.com/users/zowietao"><img title="zowietao" data-tippy-content="zowietao" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><div class="preedit px-1"><input class="block w-64 rounded-none rounded-md sm:text-sm dark:bg-gray-800 focus:outline-none focus:ring-cgray-300 dark:focus:ring-cgray-600 focus:border-cgray-300 dark:focus:border-cgray-600 border-gray-300 dark:border-gray-700" placeholder="Leave feedback..." type="text"></div><div class="form"><div class="markdown-editor is-compact is-vertical is-low-light"><div class="tabs"><dl class="tabs is-contained is-vertical"><dd class="is-active" data-tippy-content="Edit your message using markdown" data-tippy-placement="top"><a data-tab="markdown"><i class="icon-moon-edit "></i></a></dd><dd data-tippy-content="Preview your comment" data-tippy-placement="right"><a data-tab="preview"><i class="icon-moon-preview "></i></a></dd><dd data-tippy-content="Edit in full-screen mode" data-tippy-placement="bottom"><a class="js-expand"><i class="icon-moon-expand "></i></a></dd></dl><ul class="tabs-content"><li class="is-active" data-tab="markdown"><div class="text-editor-container"><div class="text-editor js-editor has-shadow"><div class="CodeMirror CodeMirror-wrap cm-s-codewars" translate="no"><div style="overflow: hidden; position: relative; width: 3px; height: 0px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; min-height: 1em; outline: none;"></textarea></div><div class="CodeMirror-vscrollbar" tabindex="-1" cm-not-content="true"><div style="min-width: 1px;"></div></div><div class="CodeMirror-hscrollbar" tabindex="-1" cm-not-content="true"><div style="height: 100%; min-height: 1px;"></div></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px;"><div style="position: relative;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre class="CodeMirror-line-like"><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-cursors"></div><div class="CodeMirror-code" role="presentation"></div></div></div></div></div><div style="position: absolute; height: 50px; width: 1px;"></div><div class="CodeMirror-gutters" style="left: 0px;"><div class="CodeMirror-gutter CodeMirror-foldgutter"></div></div></div></div><div class="editor-msg-container is-hidden"><div class="alert-box"></div></div></div><textarea style="display: none;"></textarea></div></li><li data-tab="preview"><div class="panel bg-ui-section is-overflow-auto"><div class="markdown prose max-w-none"><p>Your rendered <a rel="noopener" href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">github-flavored</a> markdown will appear here.</p></div></div></li></ul></div></div><div class="js-spoiler-flag mb-2"><label class="inline-flex items-center"><input class="rounded bg-gray-400 dark:bg-gray-600 border-transparent focus:border-transparent focus:bg-gray-400 text-gray-700 focus:ring-1 focus:ring-offset-2 dark:ring-offset-1 focus:ring-gray-500 dark:focus:ring-gray-700 dark:focus:ring-offset-gray-800" name="eRM" type="checkbox"><span class="ml-1" data-tippy-content="Check this if you are posting content that might give the answer to someone who hasn&#39;t solved the kata yet" data-tippy-placement="top">Mark as having spoiler content</span></label></div><ul class="btns"><li><a class="btn js-post">Post</a></li><li><a class="btn is-link js-cancel">Cancel</a></li></ul></div><div class="clearfix mb-15px"></div></div><div class="clearfix"></div></li><li class="mt-15px"><hr></li><li class="comment" id="602abb232463d3001c937245" data-username="OldestJunior" data-state="Open" data-label="no-label" data-context-key="qf2oa4bhd1l" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/OldestJunior"><img title="OldestJunior" data-tippy-content="OldestJunior" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/47007157"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/OldestJunior">OldestJunior</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#602abb232463d3001c937245"><time-ago lang="en" datetime="2021-02-15T18:19:15.425+0000" title="2021年2月16日 GMT+8 上午2:19">12 months ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Now, that&#39;s clever!"><p>Now, that's clever!</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="602abb232463d3001c937245"><span class="score">2</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5ec4b0411dbe7e0012c6f9a2" data-username="Colby721" data-state="Open" data-label="no-label" data-context-key="itownxhiasb" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/Colby721"><img title="Colby721" data-tippy-content="Colby721" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/Colby721">Colby721</a><span class="ml-1">(6 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5ec4b0411dbe7e0012c6f9a2"><time-ago lang="en" datetime="2020-05-20T04:21:21.883+0000" title="2020年5月20日 GMT+8 下午12:21">2 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="This solution is absolutely gorgeous and really easy to read. This is a professional solution to this problem."><p>This solution is absolutely gorgeous and really easy to read. This is a professional solution to this problem.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5ec4b0411dbe7e0012c6f9a2"><span class="score">3</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li></ul></div><div class="clearfix"></div></div></view></li><li class="js-result-group pb-30px mb-30px" data-controller="solution-group" data-solution-group-group-id-value="5d78a6c914c1b90001133f82" data-solution-group-review-id-value="52bc74d4ac05d0945d000551" id="5d78a6c914c1b90001133f82"><h6><i class="icon-moon-users "></i><a class="font-semibold" href="https://www.codewars.com/users/rabbit_binary7">rabbit_binary7</a><span>, </span><a href="https://www.codewars.com/users/d51r6759">d51r6759</a><div class="clearfix"></div></h6><pre class="p-2 overflow-x-auto"><code data-language="javascript"><span class="cm-keyword">function</span> <span class="cm-def">firstNonRepeatingLetter</span>(<span class="cm-def">s</span>) {
    <span class="cm-keyword">var</span> <span class="cm-def">map</span>, <span class="cm-def">len</span>, <span class="cm-def">i</span>, <span class="cm-def">char</span>

    <span class="cm-variable-2">map</span> <span class="cm-operator">=</span> {}
    <span class="cm-variable-2">len</span> <span class="cm-operator">=</span> <span class="cm-variable-2">s</span>.<span class="cm-property">length</span>

    <span class="cm-keyword">for</span> (<span class="cm-variable-2">i</span> <span class="cm-operator">=</span> <span class="cm-number">0</span>; <span class="cm-variable-2">i</span> <span class="cm-operator">&lt;</span> <span class="cm-variable-2">len</span>; <span class="cm-variable-2">i</span><span class="cm-operator">++</span>) {
        <span class="cm-variable-2">char</span> <span class="cm-operator">=</span> <span class="cm-variable-2">s</span>[<span class="cm-variable-2">i</span>].<span class="cm-property">toLowerCase</span>()
        <span class="cm-variable-2">map</span>[<span class="cm-variable-2">char</span>] <span class="cm-operator">=</span> (<span class="cm-variable-2">map</span>[<span class="cm-variable-2">char</span>] <span class="cm-operator">||</span> <span class="cm-number">0</span>) <span class="cm-operator">+</span> <span class="cm-number">1</span>
    }

    <span class="cm-keyword">for</span> (<span class="cm-variable-2">i</span> <span class="cm-operator">=</span> <span class="cm-number">0</span>; <span class="cm-variable-2">i</span> <span class="cm-operator">&lt;</span> <span class="cm-variable-2">len</span>; <span class="cm-variable-2">i</span><span class="cm-operator">++</span>) {
        <span class="cm-variable-2">char</span> <span class="cm-operator">=</span> <span class="cm-variable-2">s</span>[<span class="cm-variable-2">i</span>]
        <span class="cm-keyword">if</span> (<span class="cm-variable-2">map</span>[<span class="cm-variable-2">char</span>.<span class="cm-property">toLowerCase</span>()] <span class="cm-operator">==</span> <span class="cm-number">1</span>)
            <span class="cm-keyword">return</span> <span class="cm-variable-2">char</span>
    }

    <span class="cm-keyword">return</span> <span class="cm-string">''</span>
}</code></pre><div class="js-compare is-hidden" data-template="#_compare_solution"></div><div class="clearfix"></div><view data-view-data="{&quot;comments&quot;:[{&quot;id&quot;:&quot;5ff3e2700437e8001705c310&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;5fe719b37e3d3c002babf536&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5fe719b37e3d3c002babf536&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;I did something similar. All this people are using RegExps and prototype functions and increasing their time complexity. Also, with this method (by using an object instead of an array for the lookup table) you get O(1) lookup time for the mapped out characters.\n\nThe only downside with this is that it will use O(n) space. But that is how code works, gotta sacrifice space for time and vice versa.&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eI did something similar. All this people are using RegExps and prototype functions and increasing their time complexity. Also, with this method (by using an object instead of an array for the lookup table) you get O(1) lookup time for the mapped out characters.\u003c/p\u003e\n\u003cp\u003eThe only downside with this is that it will use O(n) space. But that is how code works, gotta sacrifice space for time and vice versa.\u003c/p\u003e&quot;,&quot;created_at&quot;:1609818736,&quot;created_at_datetime&quot;:&quot;2021-01-05T03:52:16.007+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#5ff3e2700437e8001705c310&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5fe719b37e3d3c002babf536&quot;,&quot;username&quot;:&quot;ozturkkl&quot;,&quot;rank_name&quot;:&quot;4 kyu&quot;,&quot;profile_path&quot;:&quot;/users/ozturkkl&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;ozturkkl\&quot; data-tippy-content=\&quot;ozturkkl\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/51798197?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5e4b71e57770f20020c570ac&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;59af0bbf485a4d1674000143&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;59af0bbf485a4d1674000143&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;This is much better with linear time complexity. Also, easier to read. \n\n&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eThis is much better with linear time complexity. Also, easier to read.\u003c/p\u003e&quot;,&quot;created_at&quot;:1582002661,&quot;created_at_datetime&quot;:&quot;2020-02-18T05:11:01.108+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#5e4b71e57770f20020c570ac&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;59af0bbf485a4d1674000143&quot;,&quot;username&quot;:&quot;qvn&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/qvn&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;qvn\&quot; data-tippy-content=\&quot;qvn\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/490241?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]}],&quot;allowedLabels&quot;:[],&quot;totalComments&quot;:2,&quot;spoilerFlag&quot;:true,&quot;commentUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/5d78a6c914c1b90001133f82/comments/%7Bcomment_id%7D&quot;,&quot;voteUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/5d78a6c914c1b90001133f82/comments/%7BrefId%7D/vote/%7Bvalue%7D&quot;,&quot;userVotesUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/5d78a6c914c1b90001133f82/comments/user_votes&quot;,&quot;labelGroups&quot;:[{&quot;name&quot;:&quot;Comments&quot;,&quot;label&quot;:null,&quot;count&quot;:2}],&quot;stateGroups&quot;:[{&quot;name&quot;:&quot;Open&quot;,&quot;count&quot;:2}]}" data-view-type="CommentsView" id="comments_list_view" class="js-rendered"><div class="view-placeholder p-15px" style="display: none;">Loading comments...</div><script type="template"><div class="comments" data-bind-data-comment-url="commentUrl" data-bind-data-vote-url="voteUrl"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="5d78a6c914c1b90001133f82"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>12</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>0</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span data-bind-text="totalComments"></span></a></li><li><a href="/kumite/new?group_id=5d78a6c914c1b90001133f82&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li data-bind-if="$solution"><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="/kata/reviews/52bc74d4ac05d0945d000551/groups/5d78a6c914c1b90001133f82">Link</a></li></ul><div class="clearfix"></div><div class="comment-label-filters" data-bind-if="labelGroups | many?"><ul class="piped-text m-4 use-alt-active-color"><li><a class="is-active" data-label="all">All</a></li><li data-bind-each="labelGroups" data-bind-if="@label"><a data-bind-data-label="@label" data-bind-id="label-{{@label}}" data-bind-text="{{@name}} ({{@count}})"></a></li></ul></div><div class="clearfix"></div><ul class="comments-list is-hidden" data-bind-user-votes-url="userVotesUrl"><include data-template="#_comment_new"></include><li class="mt-15px" data-bind-class="hr_class"><hr /></li><include data-bind-each="comments" data-template="#_comment_item"></include></ul></div><div class="clearfix"></div></script><div class="view" data-context="root"><div class="comments" data-vote-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/5d78a6c914c1b90001133f82/comments/%7BrefId%7D/vote/%7Bvalue%7D" data-comment-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/5d78a6c914c1b90001133f82/comments/%7Bcomment_id%7D"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="5d78a6c914c1b90001133f82"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>12</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>0</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span>2</span></a></li><li><a href="https://www.codewars.com/kumite/new?group_id=5d78a6c914c1b90001133f82&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="https://www.codewars.com/kata/reviews/52bc74d4ac05d0945d000551/groups/5d78a6c914c1b90001133f82">Link</a></li></ul><div class="clearfix"></div><div class="clearfix"></div><ul class="comments-list is-hidden" user-votes-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/5d78a6c914c1b90001133f82/comments/user_votes"><li class="new-comment mt-5" data-context-key="yb8j2blf3i" data-template-selector="#_comment_new"><figure><a href="https://www.codewars.com/users/zowietao"><img title="zowietao" data-tippy-content="zowietao" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><div class="preedit px-1"><input class="block w-64 rounded-none rounded-md sm:text-sm dark:bg-gray-800 focus:outline-none focus:ring-cgray-300 dark:focus:ring-cgray-600 focus:border-cgray-300 dark:focus:border-cgray-600 border-gray-300 dark:border-gray-700" placeholder="Leave feedback..." type="text"></div><div class="form"><div class="markdown-editor is-compact is-vertical is-low-light"><div class="tabs"><dl class="tabs is-contained is-vertical"><dd class="is-active" data-tippy-content="Edit your message using markdown" data-tippy-placement="top"><a data-tab="markdown"><i class="icon-moon-edit "></i></a></dd><dd data-tippy-content="Preview your comment" data-tippy-placement="right"><a data-tab="preview"><i class="icon-moon-preview "></i></a></dd><dd data-tippy-content="Edit in full-screen mode" data-tippy-placement="bottom"><a class="js-expand"><i class="icon-moon-expand "></i></a></dd></dl><ul class="tabs-content"><li class="is-active" data-tab="markdown"><div class="text-editor-container"><div class="text-editor js-editor has-shadow"><div class="CodeMirror CodeMirror-wrap cm-s-codewars" translate="no"><div style="overflow: hidden; position: relative; width: 3px; height: 0px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; min-height: 1em; outline: none;"></textarea></div><div class="CodeMirror-vscrollbar" tabindex="-1" cm-not-content="true"><div style="min-width: 1px;"></div></div><div class="CodeMirror-hscrollbar" tabindex="-1" cm-not-content="true"><div style="height: 100%; min-height: 1px;"></div></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px;"><div style="position: relative;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre class="CodeMirror-line-like"><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-cursors"></div><div class="CodeMirror-code" role="presentation"></div></div></div></div></div><div style="position: absolute; height: 50px; width: 1px;"></div><div class="CodeMirror-gutters" style="left: 0px;"><div class="CodeMirror-gutter CodeMirror-foldgutter"></div></div></div></div><div class="editor-msg-container is-hidden"><div class="alert-box"></div></div></div><textarea style="display: none;"></textarea></div></li><li data-tab="preview"><div class="panel bg-ui-section is-overflow-auto"><div class="markdown prose max-w-none"><p>Your rendered <a rel="noopener" href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">github-flavored</a> markdown will appear here.</p></div></div></li></ul></div></div><div class="js-spoiler-flag mb-2"><label class="inline-flex items-center"><input class="rounded bg-gray-400 dark:bg-gray-600 border-transparent focus:border-transparent focus:bg-gray-400 text-gray-700 focus:ring-1 focus:ring-offset-2 dark:ring-offset-1 focus:ring-gray-500 dark:focus:ring-gray-700 dark:focus:ring-offset-gray-800" name="eRM" type="checkbox"><span class="ml-1" data-tippy-content="Check this if you are posting content that might give the answer to someone who hasn&#39;t solved the kata yet" data-tippy-placement="top">Mark as having spoiler content</span></label></div><ul class="btns"><li><a class="btn js-post">Post</a></li><li><a class="btn is-link js-cancel">Cancel</a></li></ul></div><div class="clearfix mb-15px"></div></div><div class="clearfix"></div></li><li class="mt-15px"><hr></li><li class="comment" id="5ff3e2700437e8001705c310" data-username="ozturkkl" data-state="Open" data-label="no-label" data-context-key="jp2icei02oh" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/ozturkkl"><img title="ozturkkl" data-tippy-content="ozturkkl" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/51798197"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/ozturkkl">ozturkkl</a><span class="ml-1">(4 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5ff3e2700437e8001705c310"><time-ago lang="en" datetime="2021-01-05T03:52:16.007+0000" title="2021年1月5日 GMT+8 上午11:52">13 months ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="I did something similar. All this people are using RegExps and prototype functions and increasing their time complexity. Also, with this method (by using an object instead of an array for the lookup table) you get O(1) lookup time for the mapped out characters.

The only downside with this is that it will use O(n) space. But that is how code works, gotta sacrifice space for time and vice versa."><p>I did something similar. All this people are using RegExps and prototype functions and increasing their time complexity. Also, with this method (by using an object instead of an array for the lookup table) you get O(1) lookup time for the mapped out characters.</p>
<p>The only downside with this is that it will use O(n) space. But that is how code works, gotta sacrifice space for time and vice versa.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5ff3e2700437e8001705c310"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5e4b71e57770f20020c570ac" data-username="qvn" data-state="Open" data-label="no-label" data-context-key="fu6hns90v2a" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/qvn"><img title="qvn" data-tippy-content="qvn" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/490241"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/qvn">qvn</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5e4b71e57770f20020c570ac"><time-ago lang="en" datetime="2020-02-18T05:11:01.108+0000" title="2020年2月18日 GMT+8 下午1:11">2 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="This is much better with linear time complexity. Also, easier to read. 

"><p>This is much better with linear time complexity. Also, easier to read.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5e4b71e57770f20020c570ac"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li></ul></div><div class="clearfix"></div></div></view></li><li class="js-result-group pb-30px mb-30px" data-controller="solution-group" data-solution-group-group-id-value="579a26131ace7f81080004d2" data-solution-group-review-id-value="52bc74d4ac05d0945d000551" id="579a26131ace7f81080004d2"><h6><i class="icon-moon-users "></i><a class="font-semibold" href="https://www.codewars.com/users/akholod">akholod</a><span>, </span><a href="https://www.codewars.com/users/LucasL94">LucasL94</a><div class="clearfix"></div></h6><pre class="p-2 overflow-x-auto"><code data-language="javascript"><span class="cm-keyword">function</span> <span class="cm-def">firstNonRepeatingLetter</span>(<span class="cm-def">s</span>) {
    <span class="cm-keyword">var</span> <span class="cm-def">search</span> <span class="cm-operator">=</span> <span class="cm-variable-2">s</span>.<span class="cm-property">toLowerCase</span>();
    
    <span class="cm-keyword">for</span> (<span class="cm-keyword">var</span> <span class="cm-def">i</span> <span class="cm-operator">=</span> <span class="cm-number">0</span>; <span class="cm-variable-2">i</span> <span class="cm-operator">&lt;</span> <span class="cm-variable-2">search</span>.<span class="cm-property">length</span>; <span class="cm-operator">++</span><span class="cm-variable-2">i</span>) {
        <span class="cm-keyword">var</span> <span class="cm-def">str</span> <span class="cm-operator">=</span> <span class="cm-variable-2">search</span>.<span class="cm-property">slice</span>(<span class="cm-number">0</span>, <span class="cm-variable-2">i</span>) <span class="cm-operator">+</span> <span class="cm-variable-2">search</span>.<span class="cm-property">slice</span>(<span class="cm-variable-2">i</span> <span class="cm-operator">+</span> <span class="cm-number">1</span>);
        <span class="cm-keyword">if</span>((<span class="cm-variable-2">str</span>.<span class="cm-property">indexOf</span>(<span class="cm-variable-2">search</span>[<span class="cm-variable-2">i</span>]) <span class="cm-operator">===</span> <span class="cm-operator">-</span><span class="cm-number">1</span>)) {
            <span class="cm-keyword">return</span> <span class="cm-variable-2">s</span>[<span class="cm-variable-2">i</span>];
        }
    }
    <span class="cm-keyword">return</span> <span class="cm-string">''</span>;
}</code></pre><div data-controller="solution-variations" data-solution-variations-group-id-value="579a26131ace7f81080004d2" data-solution-variations-review-id-value="52bc74d4ac05d0945d000551"><div class="mt-4 mb-0 px-1 text-ui-text-lc flex justify-between"><div>1 similar code variation is grouped with this one<i class="icon-moon-info ml-1" data-tippy-content="We group similar results by ignoring whitespace, linebreaks and very minor character variations." data-tippy-placement="bottom"></i></div><button class="hidden sm:block" data-action="solution-variations#toggle">Show Variations</button></div><div class="has-top-border mt-4 pt-4 is-hidden space-y-4" data-solution-variations-target="container"></div></div><div class="js-compare is-hidden" data-template="#_compare_solution"></div><div class="clearfix"></div><view data-view-data="{&quot;comments&quot;:[],&quot;allowedLabels&quot;:[],&quot;totalComments&quot;:0,&quot;spoilerFlag&quot;:true,&quot;commentUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/579a26131ace7f81080004d2/comments/%7Bcomment_id%7D&quot;,&quot;voteUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/579a26131ace7f81080004d2/comments/%7BrefId%7D/vote/%7Bvalue%7D&quot;,&quot;userVotesUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/579a26131ace7f81080004d2/comments/user_votes&quot;,&quot;labelGroups&quot;:[],&quot;stateGroups&quot;:[]}" data-view-type="CommentsView" id="comments_list_view" class="js-rendered"><div class="view-placeholder p-15px" style="display: none;">Loading comments...</div><script type="template"><div class="comments" data-bind-data-comment-url="commentUrl" data-bind-data-vote-url="voteUrl"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="579a26131ace7f81080004d2"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>10</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>5</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span data-bind-text="totalComments"></span></a></li><li><a href="/kumite/new?group_id=579a26131ace7f81080004d2&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li data-bind-if="$solution"><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="/kata/reviews/52bc74d4ac05d0945d000551/groups/579a26131ace7f81080004d2">Link</a></li></ul><div class="clearfix"></div><div class="comment-label-filters" data-bind-if="labelGroups | many?"><ul class="piped-text m-4 use-alt-active-color"><li><a class="is-active" data-label="all">All</a></li><li data-bind-each="labelGroups" data-bind-if="@label"><a data-bind-data-label="@label" data-bind-id="label-{{@label}}" data-bind-text="{{@name}} ({{@count}})"></a></li></ul></div><div class="clearfix"></div><ul class="comments-list is-hidden" data-bind-user-votes-url="userVotesUrl"><include data-template="#_comment_new"></include><li class="mt-15px" data-bind-class="hr_class"><hr /></li><include data-bind-each="comments" data-template="#_comment_item"></include></ul></div><div class="clearfix"></div></script><div class="view" data-context="root"><div class="comments" data-vote-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/579a26131ace7f81080004d2/comments/%7BrefId%7D/vote/%7Bvalue%7D" data-comment-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/579a26131ace7f81080004d2/comments/%7Bcomment_id%7D"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="579a26131ace7f81080004d2"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>10</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>5</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span>0</span></a></li><li><a href="https://www.codewars.com/kumite/new?group_id=579a26131ace7f81080004d2&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="https://www.codewars.com/kata/reviews/52bc74d4ac05d0945d000551/groups/579a26131ace7f81080004d2">Link</a></li></ul><div class="clearfix"></div><div class="clearfix"></div><ul class="comments-list is-hidden" user-votes-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/579a26131ace7f81080004d2/comments/user_votes"><li class="new-comment mt-5" data-context-key="29y362yuql5" data-template-selector="#_comment_new"><figure><a href="https://www.codewars.com/users/zowietao"><img title="zowietao" data-tippy-content="zowietao" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><div class="preedit px-1"><input class="block w-64 rounded-none rounded-md sm:text-sm dark:bg-gray-800 focus:outline-none focus:ring-cgray-300 dark:focus:ring-cgray-600 focus:border-cgray-300 dark:focus:border-cgray-600 border-gray-300 dark:border-gray-700" placeholder="Leave feedback..." type="text"></div><div class="form"><div class="markdown-editor is-compact is-vertical is-low-light"><div class="tabs"><dl class="tabs is-contained is-vertical"><dd class="is-active" data-tippy-content="Edit your message using markdown" data-tippy-placement="top"><a data-tab="markdown"><i class="icon-moon-edit "></i></a></dd><dd data-tippy-content="Preview your comment" data-tippy-placement="right"><a data-tab="preview"><i class="icon-moon-preview "></i></a></dd><dd data-tippy-content="Edit in full-screen mode" data-tippy-placement="bottom"><a class="js-expand"><i class="icon-moon-expand "></i></a></dd></dl><ul class="tabs-content"><li class="is-active" data-tab="markdown"><div class="text-editor-container"><div class="text-editor js-editor has-shadow"><div class="CodeMirror CodeMirror-wrap cm-s-codewars" translate="no"><div style="overflow: hidden; position: relative; width: 3px; height: 0px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; min-height: 1em; outline: none;"></textarea></div><div class="CodeMirror-vscrollbar" tabindex="-1" cm-not-content="true"><div style="min-width: 1px;"></div></div><div class="CodeMirror-hscrollbar" tabindex="-1" cm-not-content="true"><div style="height: 100%; min-height: 1px;"></div></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px;"><div style="position: relative;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre class="CodeMirror-line-like"><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-cursors"></div><div class="CodeMirror-code" role="presentation"></div></div></div></div></div><div style="position: absolute; height: 50px; width: 1px;"></div><div class="CodeMirror-gutters" style="left: 0px;"><div class="CodeMirror-gutter CodeMirror-foldgutter"></div></div></div></div><div class="editor-msg-container is-hidden"><div class="alert-box"></div></div></div><textarea style="display: none;"></textarea></div></li><li data-tab="preview"><div class="panel bg-ui-section is-overflow-auto"><div class="markdown prose max-w-none"><p>Your rendered <a rel="noopener" href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">github-flavored</a> markdown will appear here.</p></div></div></li></ul></div></div><div class="js-spoiler-flag mb-2"><label class="inline-flex items-center"><input class="rounded bg-gray-400 dark:bg-gray-600 border-transparent focus:border-transparent focus:bg-gray-400 text-gray-700 focus:ring-1 focus:ring-offset-2 dark:ring-offset-1 focus:ring-gray-500 dark:focus:ring-gray-700 dark:focus:ring-offset-gray-800" name="eRM" type="checkbox"><span class="ml-1" data-tippy-content="Check this if you are posting content that might give the answer to someone who hasn&#39;t solved the kata yet" data-tippy-placement="top">Mark as having spoiler content</span></label></div><ul class="btns"><li><a class="btn js-post">Post</a></li><li><a class="btn is-link js-cancel">Cancel</a></li></ul></div><div class="clearfix mb-15px"></div></div><div class="clearfix"></div></li><li class="mt-15px is-hidden"><hr></li></ul></div><div class="clearfix"></div></div></view></li><li class="js-result-group pb-30px mb-30px" data-controller="solution-group" data-solution-group-group-id-value="5c2e642823b7c20001fb78d6" data-solution-group-review-id-value="52bc74d4ac05d0945d000551" id="5c2e642823b7c20001fb78d6"><h6><i class="icon-moon-user "></i><a class="font-semibold" href="https://www.codewars.com/users/Scorpion99">Scorpion99</a><div class="clearfix"></div></h6><pre class="p-2 overflow-x-auto"><code data-language="javascript"><span class="cm-keyword">const</span> <span class="cm-def">firstNonRepeatingLetter</span> <span class="cm-operator">=</span> <span class="cm-def">s</span> <span class="cm-operator">=&gt;</span>
  <span class="cm-variable-2">s</span>[[<span class="cm-meta">...</span><span class="cm-variable-2">s</span>.<span class="cm-property">toLowerCase</span>()].<span class="cm-property">findIndex</span>((<span class="cm-def">c</span>, <span class="cm-def">_</span>, <span class="cm-def">s</span>) <span class="cm-operator">=&gt;</span> <span class="cm-variable-2">s</span>.<span class="cm-property">indexOf</span>(<span class="cm-variable-2">c</span>) <span class="cm-operator">===</span> <span class="cm-variable-2">s</span>.<span class="cm-property">lastIndexOf</span>(<span class="cm-variable-2">c</span>))] <span class="cm-operator">||</span> <span class="cm-string">""</span>;</code></pre><div class="js-compare is-hidden" data-template="#_compare_solution"></div><div class="clearfix"></div><view data-view-data="{&quot;comments&quot;:[{&quot;id&quot;:&quot;601a2c506d5a11001775e942&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:1,&quot;user_id&quot;:&quot;599690a13acba55061000053&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;599690a13acba55061000053&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;this is the best practice&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003ethis is the best practice\u003c/p\u003e&quot;,&quot;created_at&quot;:1612328016,&quot;created_at_datetime&quot;:&quot;2021-02-03T04:53:36.274+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#601a2c506d5a11001775e942&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;599690a13acba55061000053&quot;,&quot;username&quot;:&quot;webmisfit&quot;,&quot;rank_name&quot;:&quot;3 kyu&quot;,&quot;profile_path&quot;:&quot;/users/webmisfit&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;webmisfit\&quot; data-tippy-content=\&quot;webmisfit\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://www.codewars.com/packs/assets/profile-pic.f3a90aca.png\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]}],&quot;allowedLabels&quot;:[],&quot;totalComments&quot;:1,&quot;spoilerFlag&quot;:true,&quot;commentUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/5c2e642823b7c20001fb78d6/comments/%7Bcomment_id%7D&quot;,&quot;voteUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/5c2e642823b7c20001fb78d6/comments/%7BrefId%7D/vote/%7Bvalue%7D&quot;,&quot;userVotesUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/5c2e642823b7c20001fb78d6/comments/user_votes&quot;,&quot;labelGroups&quot;:[{&quot;name&quot;:&quot;Comments&quot;,&quot;label&quot;:null,&quot;count&quot;:1}],&quot;stateGroups&quot;:[{&quot;name&quot;:&quot;Open&quot;,&quot;count&quot;:1}]}" data-view-type="CommentsView" id="comments_list_view" class="js-rendered"><div class="view-placeholder p-15px" style="display: none;">Loading comments...</div><script type="template"><div class="comments" data-bind-data-comment-url="commentUrl" data-bind-data-vote-url="voteUrl"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="5c2e642823b7c20001fb78d6"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>6</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>18</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span data-bind-text="totalComments"></span></a></li><li><a href="/kumite/new?group_id=5c2e642823b7c20001fb78d6&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li data-bind-if="$solution"><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="/kata/reviews/52bc74d4ac05d0945d000551/groups/5c2e642823b7c20001fb78d6">Link</a></li></ul><div class="clearfix"></div><div class="comment-label-filters" data-bind-if="labelGroups | many?"><ul class="piped-text m-4 use-alt-active-color"><li><a class="is-active" data-label="all">All</a></li><li data-bind-each="labelGroups" data-bind-if="@label"><a data-bind-data-label="@label" data-bind-id="label-{{@label}}" data-bind-text="{{@name}} ({{@count}})"></a></li></ul></div><div class="clearfix"></div><ul class="comments-list is-hidden" data-bind-user-votes-url="userVotesUrl"><include data-template="#_comment_new"></include><li class="mt-15px" data-bind-class="hr_class"><hr /></li><include data-bind-each="comments" data-template="#_comment_item"></include></ul></div><div class="clearfix"></div></script><div class="view" data-context="root"><div class="comments" data-vote-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/5c2e642823b7c20001fb78d6/comments/%7BrefId%7D/vote/%7Bvalue%7D" data-comment-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/5c2e642823b7c20001fb78d6/comments/%7Bcomment_id%7D"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="5c2e642823b7c20001fb78d6"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>6</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>18</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span>1</span></a></li><li><a href="https://www.codewars.com/kumite/new?group_id=5c2e642823b7c20001fb78d6&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="https://www.codewars.com/kata/reviews/52bc74d4ac05d0945d000551/groups/5c2e642823b7c20001fb78d6">Link</a></li></ul><div class="clearfix"></div><div class="clearfix"></div><ul class="comments-list is-hidden" user-votes-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/5c2e642823b7c20001fb78d6/comments/user_votes"><li class="new-comment mt-5" data-context-key="pbj2km9igi" data-template-selector="#_comment_new"><figure><a href="https://www.codewars.com/users/zowietao"><img title="zowietao" data-tippy-content="zowietao" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><div class="preedit px-1"><input class="block w-64 rounded-none rounded-md sm:text-sm dark:bg-gray-800 focus:outline-none focus:ring-cgray-300 dark:focus:ring-cgray-600 focus:border-cgray-300 dark:focus:border-cgray-600 border-gray-300 dark:border-gray-700" placeholder="Leave feedback..." type="text"></div><div class="form"><div class="markdown-editor is-compact is-vertical is-low-light"><div class="tabs"><dl class="tabs is-contained is-vertical"><dd class="is-active" data-tippy-content="Edit your message using markdown" data-tippy-placement="top"><a data-tab="markdown"><i class="icon-moon-edit "></i></a></dd><dd data-tippy-content="Preview your comment" data-tippy-placement="right"><a data-tab="preview"><i class="icon-moon-preview "></i></a></dd><dd data-tippy-content="Edit in full-screen mode" data-tippy-placement="bottom"><a class="js-expand"><i class="icon-moon-expand "></i></a></dd></dl><ul class="tabs-content"><li class="is-active" data-tab="markdown"><div class="text-editor-container"><div class="text-editor js-editor has-shadow"><div class="CodeMirror CodeMirror-wrap cm-s-codewars" translate="no"><div style="overflow: hidden; position: relative; width: 3px; height: 0px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; min-height: 1em; outline: none;"></textarea></div><div class="CodeMirror-vscrollbar" tabindex="-1" cm-not-content="true"><div style="min-width: 1px;"></div></div><div class="CodeMirror-hscrollbar" tabindex="-1" cm-not-content="true"><div style="height: 100%; min-height: 1px;"></div></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px;"><div style="position: relative;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre class="CodeMirror-line-like"><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-cursors"></div><div class="CodeMirror-code" role="presentation"></div></div></div></div></div><div style="position: absolute; height: 50px; width: 1px;"></div><div class="CodeMirror-gutters" style="left: 0px;"><div class="CodeMirror-gutter CodeMirror-foldgutter"></div></div></div></div><div class="editor-msg-container is-hidden"><div class="alert-box"></div></div></div><textarea style="display: none;"></textarea></div></li><li data-tab="preview"><div class="panel bg-ui-section is-overflow-auto"><div class="markdown prose max-w-none"><p>Your rendered <a rel="noopener" href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">github-flavored</a> markdown will appear here.</p></div></div></li></ul></div></div><div class="js-spoiler-flag mb-2"><label class="inline-flex items-center"><input class="rounded bg-gray-400 dark:bg-gray-600 border-transparent focus:border-transparent focus:bg-gray-400 text-gray-700 focus:ring-1 focus:ring-offset-2 dark:ring-offset-1 focus:ring-gray-500 dark:focus:ring-gray-700 dark:focus:ring-offset-gray-800" name="eRM" type="checkbox"><span class="ml-1" data-tippy-content="Check this if you are posting content that might give the answer to someone who hasn&#39;t solved the kata yet" data-tippy-placement="top">Mark as having spoiler content</span></label></div><ul class="btns"><li><a class="btn js-post">Post</a></li><li><a class="btn is-link js-cancel">Cancel</a></li></ul></div><div class="clearfix mb-15px"></div></div><div class="clearfix"></div></li><li class="mt-15px"><hr></li><li class="comment" id="601a2c506d5a11001775e942" data-username="webmisfit" data-state="Open" data-label="no-label" data-context-key="bgb2e7iszb" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/webmisfit"><img title="webmisfit" data-tippy-content="webmisfit" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/webmisfit">webmisfit</a><span class="ml-1">(3 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#601a2c506d5a11001775e942"><time-ago lang="en" datetime="2021-02-03T04:53:36.274+0000" title="2021年2月3日 GMT+8 下午12:53">12 months ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="this is the best practice"><p>this is the best practice</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="601a2c506d5a11001775e942"><span class="score">1</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li></ul></div><div class="clearfix"></div></div></view></li><li class="js-result-group pb-30px mb-30px" data-controller="solution-group" data-solution-group-group-id-value="57a344b3bb9944d6ec000a05" data-solution-group-review-id-value="52bc74d4ac05d0945d000551" id="57a344b3bb9944d6ec000a05"><h6><i class="icon-moon-users "></i><a class="font-semibold" href="https://www.codewars.com/users/sashapd">sashapd</a><span>, </span><a href="https://www.codewars.com/users/jimmy-collazos">jimmy-collazos</a><span>, </span><a href="https://www.codewars.com/users/Sacred6661">Sacred6661</a><span>, </span><a href="https://www.codewars.com/users/shettyadithya">shettyadithya</a><span>, </span><a href="https://www.codewars.com/users/jorge.montenegro">jorge.montenegro</a><span>, </span><a href="https://www.codewars.com/users/Myke">Myke</a><span>, </span><a href="https://www.codewars.com/users/charleston1395">charleston1395</a><span>, </span><a href="https://www.codewars.com/users/salah-200">salah-200</a><span>, </span><a href="https://www.codewars.com/users/takwa%20mabrouki">takwa mabrouki</a><span>, </span><a href="https://www.codewars.com/users/aleclogronio">aleclogronio</a><span> (plus 33 more warriors)</span><div class="clearfix"></div></h6><pre class="p-2 overflow-x-auto"><code data-language="javascript"><span class="cm-keyword">function</span> <span class="cm-def">firstNonRepeatingLetter</span>(<span class="cm-def">s</span>) {
  <span class="cm-keyword">return</span> <span class="cm-variable-2">s</span>[<span class="cm-variable-2">s</span>.<span class="cm-property">toLowerCase</span>().<span class="cm-property">split</span>(<span class="cm-string">''</span>).<span class="cm-property">findIndex</span>(<span class="cm-def">letter</span> <span class="cm-operator">=&gt;</span> <span class="cm-variable-2">s</span>.<span class="cm-property">toLowerCase</span>().<span class="cm-property">split</span>(<span class="cm-string">''</span>).<span class="cm-property">filter</span>(<span class="cm-def">l</span> <span class="cm-operator">=&gt;</span> <span class="cm-variable-2">l</span> <span class="cm-operator">===</span> <span class="cm-variable-2">letter</span>).<span class="cm-property">length</span> <span class="cm-operator">===</span> <span class="cm-number">1</span> )] <span class="cm-operator">||</span> <span class="cm-string">''</span>;
}</code></pre><div data-controller="solution-variations" data-solution-variations-group-id-value="57a344b3bb9944d6ec000a05" data-solution-variations-review-id-value="52bc74d4ac05d0945d000551"><div class="mt-4 mb-0 px-1 text-ui-text-lc flex justify-between"><div>13 similar code variations are grouped with this one<i class="icon-moon-info ml-1" data-tippy-content="We group similar results by ignoring whitespace, linebreaks and very minor character variations." data-tippy-placement="bottom"></i></div><button class="hidden sm:block" data-action="solution-variations#toggle">Show Variations</button></div><div class="has-top-border mt-4 pt-4 is-hidden space-y-4" data-solution-variations-target="container"></div></div><div class="js-compare is-hidden" data-template="#_compare_solution"></div><div class="clearfix"></div><view data-view-data="{&quot;comments&quot;:[{&quot;id&quot;:&quot;6010b341e0226d000f85ae37&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:2,&quot;user_id&quot;:&quot;5d6ea9a0aa004c002566eb40&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5d6ea9a0aa004c002566eb40&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Remember not only to say the right thing in the right place, but far more difficult still, to leave unsaid the wrong thing at the tempting moment.&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eRemember not only to say the right thing in the right place, but far more difficult still, to leave unsaid the wrong thing at the tempting moment.\u003c/p\u003e&quot;,&quot;created_at&quot;:1611707201,&quot;created_at_datetime&quot;:&quot;2021-01-27T00:26:41.088+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:1,&quot;hash&quot;:&quot;#6010b341e0226d000f85ae37&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5d6ea9a0aa004c002566eb40&quot;,&quot;username&quot;:&quot;charleston1395&quot;,&quot;rank_name&quot;:&quot;4 kyu&quot;,&quot;profile_path&quot;:&quot;/users/charleston1395&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;charleston1395\&quot; data-tippy-content=\&quot;charleston1395\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/54860301?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[{&quot;id&quot;:&quot;6010d8e38136ca002bc9ced9&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:2,&quot;user_id&quot;:&quot;5fdcb330521370000ee710d7&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5fdcb330521370000ee710d7&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;It has been said, \&quot;The blues live in the notes you don&#39;t play\&quot;&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eIt has been said, \&quot;The blues live in the notes you don&#39;t play\&quot;\u003c/p\u003e&quot;,&quot;created_at&quot;:1611716835,&quot;created_at_datetime&quot;:&quot;2021-01-27T03:07:15.713+0000&quot;,&quot;nest_level&quot;:1,&quot;collapsed&quot;:false,&quot;total_comments&quot;:null,&quot;hash&quot;:&quot;#6010d8e38136ca002bc9ced9&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5fdcb330521370000ee710d7&quot;,&quot;username&quot;:&quot;karaeg-san&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/karaeg-san&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;karaeg-san\&quot; data-tippy-content=\&quot;karaeg-san\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/16840272?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]}]},{&quot;id&quot;:&quot;6010add17c6710000998ccf9&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:2,&quot;user_id&quot;:&quot;5fdcb330521370000ee710d7&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5fdcb330521370000ee710d7&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;Don&#39;t say much, do ya? ;)&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eDon&#39;t say much, do ya? ;)\u003c/p\u003e&quot;,&quot;created_at&quot;:1611705809,&quot;created_at_datetime&quot;:&quot;2021-01-27T00:03:29.709+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#6010add17c6710000998ccf9&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5fdcb330521370000ee710d7&quot;,&quot;username&quot;:&quot;karaeg-san&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/karaeg-san&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;karaeg-san\&quot; data-tippy-content=\&quot;karaeg-san\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/16840272?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]},{&quot;id&quot;:&quot;5ba39d98154f607aee0001d0&quot;,&quot;masked&quot;:true,&quot;masked_by_id&quot;:&quot;5d6ea9a0aa004c002566eb40&quot;,&quot;votes_score&quot;:4,&quot;user_id&quot;:&quot;52d5584d6b02b266e70005e1&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;52d5584d6b02b266e70005e1&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;I really enjoy this one, definitely an approach I didn&#39;t think of. &quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eI really enjoy this one, definitely an approach I didn&#39;t think of.\u003c/p\u003e&quot;,&quot;created_at&quot;:1537449368,&quot;created_at_datetime&quot;:&quot;2018-09-20T13:16:08.881+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#5ba39d98154f607aee0001d0&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;52d5584d6b02b266e70005e1&quot;,&quot;username&quot;:&quot;dputman&quot;,&quot;rank_name&quot;:&quot;5 kyu&quot;,&quot;profile_path&quot;:&quot;/users/dputman&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;dputman\&quot; data-tippy-content=\&quot;dputman\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/5446859?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]}],&quot;allowedLabels&quot;:[],&quot;totalComments&quot;:4,&quot;spoilerFlag&quot;:true,&quot;commentUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/57a344b3bb9944d6ec000a05/comments/%7Bcomment_id%7D&quot;,&quot;voteUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/57a344b3bb9944d6ec000a05/comments/%7BrefId%7D/vote/%7Bvalue%7D&quot;,&quot;userVotesUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/57a344b3bb9944d6ec000a05/comments/user_votes&quot;,&quot;labelGroups&quot;:[{&quot;name&quot;:&quot;Comments&quot;,&quot;label&quot;:null,&quot;count&quot;:3}],&quot;stateGroups&quot;:[{&quot;name&quot;:&quot;Open&quot;,&quot;count&quot;:3}]}" data-view-type="CommentsView" id="comments_list_view" class="js-rendered"><div class="view-placeholder p-15px" style="display: none;">Loading comments...</div><script type="template"><div class="comments" data-bind-data-comment-url="commentUrl" data-bind-data-vote-url="voteUrl"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="57a344b3bb9944d6ec000a05"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>4</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>49</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span data-bind-text="totalComments"></span></a></li><li><a href="/kumite/new?group_id=57a344b3bb9944d6ec000a05&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li data-bind-if="$solution"><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="/kata/reviews/52bc74d4ac05d0945d000551/groups/57a344b3bb9944d6ec000a05">Link</a></li></ul><div class="clearfix"></div><div class="comment-label-filters" data-bind-if="labelGroups | many?"><ul class="piped-text m-4 use-alt-active-color"><li><a class="is-active" data-label="all">All</a></li><li data-bind-each="labelGroups" data-bind-if="@label"><a data-bind-data-label="@label" data-bind-id="label-{{@label}}" data-bind-text="{{@name}} ({{@count}})"></a></li></ul></div><div class="clearfix"></div><ul class="comments-list is-hidden" data-bind-user-votes-url="userVotesUrl"><include data-template="#_comment_new"></include><li class="mt-15px" data-bind-class="hr_class"><hr /></li><include data-bind-each="comments" data-template="#_comment_item"></include></ul></div><div class="clearfix"></div></script><div class="view" data-context="root"><div class="comments" data-vote-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/57a344b3bb9944d6ec000a05/comments/%7BrefId%7D/vote/%7Bvalue%7D" data-comment-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/57a344b3bb9944d6ec000a05/comments/%7Bcomment_id%7D"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="57a344b3bb9944d6ec000a05"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>4</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>49</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span>4</span></a></li><li><a href="https://www.codewars.com/kumite/new?group_id=57a344b3bb9944d6ec000a05&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="https://www.codewars.com/kata/reviews/52bc74d4ac05d0945d000551/groups/57a344b3bb9944d6ec000a05">Link</a></li></ul><div class="clearfix"></div><div class="clearfix"></div><ul class="comments-list is-hidden" user-votes-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/57a344b3bb9944d6ec000a05/comments/user_votes"><li class="new-comment mt-5" data-context-key="1ekggjnfvsb" data-template-selector="#_comment_new"><figure><a href="https://www.codewars.com/users/zowietao"><img title="zowietao" data-tippy-content="zowietao" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><div class="preedit px-1"><input class="block w-64 rounded-none rounded-md sm:text-sm dark:bg-gray-800 focus:outline-none focus:ring-cgray-300 dark:focus:ring-cgray-600 focus:border-cgray-300 dark:focus:border-cgray-600 border-gray-300 dark:border-gray-700" placeholder="Leave feedback..." type="text"></div><div class="form"><div class="markdown-editor is-compact is-vertical is-low-light"><div class="tabs"><dl class="tabs is-contained is-vertical"><dd class="is-active" data-tippy-content="Edit your message using markdown" data-tippy-placement="top"><a data-tab="markdown"><i class="icon-moon-edit "></i></a></dd><dd data-tippy-content="Preview your comment" data-tippy-placement="right"><a data-tab="preview"><i class="icon-moon-preview "></i></a></dd><dd data-tippy-content="Edit in full-screen mode" data-tippy-placement="bottom"><a class="js-expand"><i class="icon-moon-expand "></i></a></dd></dl><ul class="tabs-content"><li class="is-active" data-tab="markdown"><div class="text-editor-container"><div class="text-editor js-editor has-shadow"><div class="CodeMirror CodeMirror-wrap cm-s-codewars" translate="no"><div style="overflow: hidden; position: relative; width: 3px; height: 0px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; min-height: 1em; outline: none;"></textarea></div><div class="CodeMirror-vscrollbar" tabindex="-1" cm-not-content="true"><div style="min-width: 1px;"></div></div><div class="CodeMirror-hscrollbar" tabindex="-1" cm-not-content="true"><div style="height: 100%; min-height: 1px;"></div></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px;"><div style="position: relative;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre class="CodeMirror-line-like"><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-cursors"></div><div class="CodeMirror-code" role="presentation"></div></div></div></div></div><div style="position: absolute; height: 50px; width: 1px;"></div><div class="CodeMirror-gutters" style="left: 0px;"><div class="CodeMirror-gutter CodeMirror-foldgutter"></div></div></div></div><div class="editor-msg-container is-hidden"><div class="alert-box"></div></div></div><textarea style="display: none;"></textarea></div></li><li data-tab="preview"><div class="panel bg-ui-section is-overflow-auto"><div class="markdown prose max-w-none"><p>Your rendered <a rel="noopener" href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">github-flavored</a> markdown will appear here.</p></div></div></li></ul></div></div><div class="js-spoiler-flag mb-2"><label class="inline-flex items-center"><input class="rounded bg-gray-400 dark:bg-gray-600 border-transparent focus:border-transparent focus:bg-gray-400 text-gray-700 focus:ring-1 focus:ring-offset-2 dark:ring-offset-1 focus:ring-gray-500 dark:focus:ring-gray-700 dark:focus:ring-offset-gray-800" name="eRM" type="checkbox"><span class="ml-1" data-tippy-content="Check this if you are posting content that might give the answer to someone who hasn&#39;t solved the kata yet" data-tippy-placement="top">Mark as having spoiler content</span></label></div><ul class="btns"><li><a class="btn js-post">Post</a></li><li><a class="btn is-link js-cancel">Cancel</a></li></ul></div><div class="clearfix mb-15px"></div></div><div class="clearfix"></div></li><li class="mt-15px"><hr></li><li class="comment" id="6010b341e0226d000f85ae37" data-username="charleston1395" data-state="Open" data-label="no-label" data-context-key="488bbc4d9zf" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/charleston1395"><img title="charleston1395" data-tippy-content="charleston1395" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/54860301"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/charleston1395">charleston1395</a><span class="ml-1">(4 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#6010b341e0226d000f85ae37"><time-ago lang="en" datetime="2021-01-27T00:26:41.088+0000" title="2021年1月27日 GMT+8 上午8:26">12 months ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Remember not only to say the right thing in the right place, but far more difficult still, to leave unsaid the wrong thing at the tempting moment."><p>Remember not only to say the right thing in the right place, but far more difficult still, to leave unsaid the wrong thing at the tempting moment.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="6010b341e0226d000f85ae37"><span class="score">2</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand 1 Reply</span></a></li><li><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments"><ul class="comments-list"><li class="comment" id="6010d8e38136ca002bc9ced9" data-username="karaeg-san" data-state="Open" data-label="no-label" data-context-key="xadkhxcnjtc" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/karaeg-san"><img title="karaeg-san" data-tippy-content="karaeg-san" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/16840272"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/karaeg-san">karaeg-san</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#6010d8e38136ca002bc9ced9"><time-ago lang="en" datetime="2021-01-27T03:07:15.713+0000" title="2021年1月27日 GMT+8 上午11:07">12 months ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="It has been said, &quot;The blues live in the notes you don&#39;t play&quot;"><p>It has been said, "The blues live in the notes you don't play"</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="6010d8e38136ca002bc9ced9"><span class="score">2</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li></ul></div><ul class="js-actions-bar comment-actions is-auto-hidden bulleted-text"><li><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li></ul></div></li><li class="comment" id="6010add17c6710000998ccf9" data-username="karaeg-san" data-state="Open" data-label="no-label" data-context-key="f4c7lg0g12r" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/karaeg-san"><img title="karaeg-san" data-tippy-content="karaeg-san" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/16840272"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/karaeg-san">karaeg-san</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#6010add17c6710000998ccf9"><time-ago lang="en" datetime="2021-01-27T00:03:29.709+0000" title="2021年1月27日 GMT+8 上午8:03">12 months ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="Don&#39;t say much, do ya? ;)"><p>Don't say much, do ya? ;)</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="6010add17c6710000998ccf9"><span class="score">2</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li><li class="comment" id="5ba39d98154f607aee0001d0" data-username="dputman" data-state="Open" data-label="no-label" data-context-key="w7iak9afdr" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/dputman"><img title="dputman" data-tippy-content="dputman" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/5446859"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/dputman">dputman</a><span class="ml-1">(5 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5ba39d98154f607aee0001d0"><time-ago lang="en" datetime="2018-09-20T13:16:08.881+0000" title="2018年9月20日 GMT+8 下午9:16">3 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="I really enjoy this one, definitely an approach I didn&#39;t think of. "><p>I really enjoy this one, definitely an approach I didn't think of.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5ba39d98154f607aee0001d0"><span class="score">4</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden is-active"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" flag-masked-by="5d6ea9a0aa004c002566eb40" flag-masked="true" data-tippy-content="Un-flag this comment as having spoilers within it."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li></ul></div><div class="clearfix"></div></div></view></li><li class="js-result-group pb-30px mb-30px" data-controller="solution-group" data-solution-group-group-id-value="5cf446c42ad4650001f8d8be" data-solution-group-review-id-value="52bc74d4ac05d0945d000551" id="5cf446c42ad4650001f8d8be"><h6><i class="icon-moon-user "></i><a class="font-semibold" href="https://www.codewars.com/users/khlivnyuk">khlivnyuk</a><div class="clearfix"></div></h6><pre class="p-2 overflow-x-auto"><code data-language="javascript"><span class="cm-keyword">const</span> <span class="cm-def">firstNonRepeatingLetter</span> <span class="cm-operator">=</span> <span class="cm-def">s</span> <span class="cm-operator">=&gt;</span> [<span class="cm-meta">...</span><span class="cm-variable-2">s</span>].<span class="cm-property">find</span>(<span class="cm-def">ch</span> <span class="cm-operator">=&gt;</span> <span class="cm-variable-2">s</span>.<span class="cm-property">match</span>(<span class="cm-keyword">new</span> <span class="cm-variable">RegExp</span>(<span class="cm-variable-2">ch</span>, <span class="cm-string">'gi'</span>)).<span class="cm-property">length</span> <span class="cm-operator">===</span> <span class="cm-number">1</span>) <span class="cm-operator">||</span><span class="cm-string">''</span>;</code></pre><div class="js-compare is-hidden" data-template="#_compare_solution"></div><div class="clearfix"></div><view data-view-data="{&quot;comments&quot;:[],&quot;allowedLabels&quot;:[],&quot;totalComments&quot;:0,&quot;spoilerFlag&quot;:true,&quot;commentUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/5cf446c42ad4650001f8d8be/comments/%7Bcomment_id%7D&quot;,&quot;voteUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/5cf446c42ad4650001f8d8be/comments/%7BrefId%7D/vote/%7Bvalue%7D&quot;,&quot;userVotesUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/5cf446c42ad4650001f8d8be/comments/user_votes&quot;,&quot;labelGroups&quot;:[],&quot;stateGroups&quot;:[]}" data-view-type="CommentsView" id="comments_list_view" class="js-rendered"><div class="view-placeholder p-15px" style="display: none;">Loading comments...</div><script type="template"><div class="comments" data-bind-data-comment-url="commentUrl" data-bind-data-vote-url="voteUrl"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="5cf446c42ad4650001f8d8be"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>3</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>4</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span data-bind-text="totalComments"></span></a></li><li><a href="/kumite/new?group_id=5cf446c42ad4650001f8d8be&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li data-bind-if="$solution"><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="/kata/reviews/52bc74d4ac05d0945d000551/groups/5cf446c42ad4650001f8d8be">Link</a></li></ul><div class="clearfix"></div><div class="comment-label-filters" data-bind-if="labelGroups | many?"><ul class="piped-text m-4 use-alt-active-color"><li><a class="is-active" data-label="all">All</a></li><li data-bind-each="labelGroups" data-bind-if="@label"><a data-bind-data-label="@label" data-bind-id="label-{{@label}}" data-bind-text="{{@name}} ({{@count}})"></a></li></ul></div><div class="clearfix"></div><ul class="comments-list is-hidden" data-bind-user-votes-url="userVotesUrl"><include data-template="#_comment_new"></include><li class="mt-15px" data-bind-class="hr_class"><hr /></li><include data-bind-each="comments" data-template="#_comment_item"></include></ul></div><div class="clearfix"></div></script><div class="view" data-context="root"><div class="comments" data-vote-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/5cf446c42ad4650001f8d8be/comments/%7BrefId%7D/vote/%7Bvalue%7D" data-comment-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/5cf446c42ad4650001f8d8be/comments/%7Bcomment_id%7D"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="5cf446c42ad4650001f8d8be"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>3</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>4</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span>0</span></a></li><li><a href="https://www.codewars.com/kumite/new?group_id=5cf446c42ad4650001f8d8be&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="https://www.codewars.com/kata/reviews/52bc74d4ac05d0945d000551/groups/5cf446c42ad4650001f8d8be">Link</a></li></ul><div class="clearfix"></div><div class="clearfix"></div><ul class="comments-list is-hidden" user-votes-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/5cf446c42ad4650001f8d8be/comments/user_votes"><li class="new-comment mt-5" data-context-key="ho95mcscd3a" data-template-selector="#_comment_new"><figure><a href="https://www.codewars.com/users/zowietao"><img title="zowietao" data-tippy-content="zowietao" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><div class="preedit px-1"><input class="block w-64 rounded-none rounded-md sm:text-sm dark:bg-gray-800 focus:outline-none focus:ring-cgray-300 dark:focus:ring-cgray-600 focus:border-cgray-300 dark:focus:border-cgray-600 border-gray-300 dark:border-gray-700" placeholder="Leave feedback..." type="text"></div><div class="form"><div class="markdown-editor is-compact is-vertical is-low-light"><div class="tabs"><dl class="tabs is-contained is-vertical"><dd class="is-active" data-tippy-content="Edit your message using markdown" data-tippy-placement="top"><a data-tab="markdown"><i class="icon-moon-edit "></i></a></dd><dd data-tippy-content="Preview your comment" data-tippy-placement="right"><a data-tab="preview"><i class="icon-moon-preview "></i></a></dd><dd data-tippy-content="Edit in full-screen mode" data-tippy-placement="bottom"><a class="js-expand"><i class="icon-moon-expand "></i></a></dd></dl><ul class="tabs-content"><li class="is-active" data-tab="markdown"><div class="text-editor-container"><div class="text-editor js-editor has-shadow"><div class="CodeMirror CodeMirror-wrap cm-s-codewars" translate="no"><div style="overflow: hidden; position: relative; width: 3px; height: 0px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; min-height: 1em; outline: none;"></textarea></div><div class="CodeMirror-vscrollbar" tabindex="-1" cm-not-content="true"><div style="min-width: 1px;"></div></div><div class="CodeMirror-hscrollbar" tabindex="-1" cm-not-content="true"><div style="height: 100%; min-height: 1px;"></div></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px;"><div style="position: relative;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre class="CodeMirror-line-like"><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-cursors"></div><div class="CodeMirror-code" role="presentation"></div></div></div></div></div><div style="position: absolute; height: 50px; width: 1px;"></div><div class="CodeMirror-gutters" style="left: 0px;"><div class="CodeMirror-gutter CodeMirror-foldgutter"></div></div></div></div><div class="editor-msg-container is-hidden"><div class="alert-box"></div></div></div><textarea style="display: none;"></textarea></div></li><li data-tab="preview"><div class="panel bg-ui-section is-overflow-auto"><div class="markdown prose max-w-none"><p>Your rendered <a rel="noopener" href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">github-flavored</a> markdown will appear here.</p></div></div></li></ul></div></div><div class="js-spoiler-flag mb-2"><label class="inline-flex items-center"><input class="rounded bg-gray-400 dark:bg-gray-600 border-transparent focus:border-transparent focus:bg-gray-400 text-gray-700 focus:ring-1 focus:ring-offset-2 dark:ring-offset-1 focus:ring-gray-500 dark:focus:ring-gray-700 dark:focus:ring-offset-gray-800" name="eRM" type="checkbox"><span class="ml-1" data-tippy-content="Check this if you are posting content that might give the answer to someone who hasn&#39;t solved the kata yet" data-tippy-placement="top">Mark as having spoiler content</span></label></div><ul class="btns"><li><a class="btn js-post">Post</a></li><li><a class="btn is-link js-cancel">Cancel</a></li></ul></div><div class="clearfix mb-15px"></div></div><div class="clearfix"></div></li><li class="mt-15px is-hidden"><hr></li></ul></div><div class="clearfix"></div></div></view></li><li class="js-result-group pb-30px mb-30px" data-controller="solution-group" data-solution-group-group-id-value="53fb5634143fd84e940005da" data-solution-group-review-id-value="52bc74d4ac05d0945d000551" id="53fb5634143fd84e940005da"><h6><i class="icon-moon-user "></i><a class="font-semibold" href="https://www.codewars.com/users/jacksonhoose">jacksonhoose</a><div class="clearfix"></div></h6><pre class="p-2 overflow-x-auto"><code data-language="javascript"><span class="cm-keyword">function</span> <span class="cm-def">firstNonRepeatingLetter</span>(<span class="cm-def">s</span>) {
  <span class="cm-keyword">var</span> <span class="cm-def">unique</span> <span class="cm-operator">=</span> {};
  
  <span class="cm-keyword">if</span>(<span class="cm-variable-2">s</span>.<span class="cm-property">length</span> <span class="cm-operator">===</span> <span class="cm-number">0</span>) <span class="cm-keyword">return</span> <span class="cm-string">''</span>;
  
  <span class="cm-variable-2">s</span>.<span class="cm-property">split</span>(<span class="cm-string">''</span>).<span class="cm-property">forEach</span>(<span class="cm-keyword">function</span>(<span class="cm-def">val</span>, <span class="cm-def">i</span>) { 
    <span class="cm-keyword">var</span> <span class="cm-def">lowerVal</span> <span class="cm-operator">=</span> <span class="cm-variable-2">val</span>.<span class="cm-property">toLowerCase</span>();
    <span class="cm-keyword">if</span>(<span class="cm-operator">!</span><span class="cm-variable-2">unique</span>.<span class="cm-property">hasOwnProperty</span>(<span class="cm-variable-2">lowerVal</span>)) {
      <span class="cm-variable-2">unique</span>[<span class="cm-variable-2">lowerVal</span>] <span class="cm-operator">=</span> [];
    }
    <span class="cm-variable-2">unique</span>[<span class="cm-variable-2">lowerVal</span>].<span class="cm-property">push</span>(<span class="cm-variable-2">val</span>);
  });
  
  <span class="cm-keyword">for</span>(<span class="cm-keyword">var</span> <span class="cm-def">prop</span> <span class="cm-keyword">in</span> <span class="cm-variable-2">unique</span>) {
    <span class="cm-keyword">if</span>(<span class="cm-variable-2">unique</span>[<span class="cm-variable-2">prop</span>].<span class="cm-property">length</span> <span class="cm-operator">===</span> <span class="cm-number">1</span>) <span class="cm-keyword">return</span> <span class="cm-variable-2">unique</span>[<span class="cm-variable-2">prop</span>][<span class="cm-number">0</span>];
  }
  
  <span class="cm-keyword">return</span> <span class="cm-string">''</span>;
  
}</code></pre><div class="js-compare is-hidden" data-template="#_compare_solution"></div><div class="clearfix"></div><view data-view-data="{&quot;comments&quot;:[{&quot;id&quot;:&quot;5b515677578c6a66320000a7&quot;,&quot;masked&quot;:null,&quot;masked_by_id&quot;:null,&quot;votes_score&quot;:3,&quot;user_id&quot;:&quot;5b4ff8d2bdd07497990007cc&quot;,&quot;edit_count&quot;:0,&quot;label&quot;:null,&quot;resolvable?&quot;:false,&quot;allowed_resolver_ids&quot;:[&quot;5b4ff8d2bdd07497990007cc&quot;],&quot;state&quot;:&quot;fresh&quot;,&quot;state_text&quot;:&quot;new&quot;,&quot;state_summary&quot;:&quot;Open&quot;,&quot;type&quot;:&quot;&quot;,&quot;label_text&quot;:null,&quot;markdown&quot;:&quot;I like your style and that you find the solution in linear time complexity.  I just have two comments:  Why have an array for each character instead of just having a count for each?  Also, seems like a bad practice to count on object keys being returned in the order they were added.&quot;,&quot;markdown_html&quot;:&quot;\u003cp\u003eI like your style and that you find the solution in linear time complexity.  I just have two comments:  Why have an array for each character instead of just having a count for each?  Also, seems like a bad practice to count on object keys being returned in the order they were added.\u003c/p\u003e&quot;,&quot;created_at&quot;:1532057207,&quot;created_at_datetime&quot;:&quot;2018-07-20T03:26:47.697+0000&quot;,&quot;nest_level&quot;:0,&quot;collapsed&quot;:false,&quot;total_comments&quot;:0,&quot;hash&quot;:&quot;#5b515677578c6a66320000a7&quot;,&quot;user&quot;:{&quot;id&quot;:&quot;5b4ff8d2bdd07497990007cc&quot;,&quot;username&quot;:&quot;snydergd&quot;,&quot;rank_name&quot;:&quot;6 kyu&quot;,&quot;profile_path&quot;:&quot;/users/snydergd&quot;,&quot;avatar_tag&quot;:&quot;\u003cimg title=\&quot;snydergd\&quot; data-tippy-content=\&quot;snydergd\&quot; data-tippy-placement=\&quot;bottom\&quot; src=\&quot;https://avatars.githubusercontent.com/u/1040083?s=100\&quot; /\u003e&quot;,&quot;is_admin&quot;:false,&quot;is_mod&quot;:false},&quot;comments&quot;:[]}],&quot;allowedLabels&quot;:[],&quot;totalComments&quot;:1,&quot;spoilerFlag&quot;:true,&quot;commentUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/53fb5634143fd84e940005da/comments/%7Bcomment_id%7D&quot;,&quot;voteUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/53fb5634143fd84e940005da/comments/%7BrefId%7D/vote/%7Bvalue%7D&quot;,&quot;userVotesUrl&quot;:&quot;/kata/reviews/52bc74d4ac05d0945d000551/groups/53fb5634143fd84e940005da/comments/user_votes&quot;,&quot;labelGroups&quot;:[{&quot;name&quot;:&quot;Comments&quot;,&quot;label&quot;:null,&quot;count&quot;:1}],&quot;stateGroups&quot;:[{&quot;name&quot;:&quot;Open&quot;,&quot;count&quot;:1}]}" data-view-type="CommentsView" id="comments_list_view" class="js-rendered"><div class="view-placeholder p-15px" style="display: none;">Loading comments...</div><script type="template"><div class="comments" data-bind-data-comment-url="commentUrl" data-bind-data-vote-url="voteUrl"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="53fb5634143fd84e940005da"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>3</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>1</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span data-bind-text="totalComments"></span></a></li><li><a href="/kumite/new?group_id=53fb5634143fd84e940005da&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li data-bind-if="$solution"><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="/kata/reviews/52bc74d4ac05d0945d000551/groups/53fb5634143fd84e940005da">Link</a></li></ul><div class="clearfix"></div><div class="comment-label-filters" data-bind-if="labelGroups | many?"><ul class="piped-text m-4 use-alt-active-color"><li><a class="is-active" data-label="all">All</a></li><li data-bind-each="labelGroups" data-bind-if="@label"><a data-bind-data-label="@label" data-bind-id="label-{{@label}}" data-bind-text="{{@name}} ({{@count}})"></a></li></ul></div><div class="clearfix"></div><ul class="comments-list is-hidden" data-bind-user-votes-url="userVotesUrl"><include data-template="#_comment_new"></include><li class="mt-15px" data-bind-class="hr_class"><hr /></li><include data-bind-each="comments" data-template="#_comment_item"></include></ul></div><div class="clearfix"></div></script><div class="view" data-context="root"><div class="comments" data-vote-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/53fb5634143fd84e940005da/comments/%7BrefId%7D/vote/%7Bvalue%7D" data-comment-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/53fb5634143fd84e940005da/comments/%7Bcomment_id%7D"><ul class="piped-text mt-4 has-keyword-tags"><li><ul class="vote-labels" data-vote-name="solution-solution_group" data-vote-ref-id="53fb5634143fd84e940005da"><li data-tippy-content="Vote this solution as a best practice. Best practice solutions tend to be a good balance of performance, readability and maintainability." data-tippy-placement="bottom"><a class="vote-label" data-label="best_practice"><i class="icon-moon-up "></i>Best Practices<span>3</span></a></li><li data-tippy-content="Vote this solution as being clever. Clever solutions tend to be very creative or make use of obscure language features. They usually are not code that you would want to put into production." data-tippy-placement="bottom"><a class="vote-label" data-label="clever"><i class="icon-moon-up "></i>Clever<span>1</span></a></li></ul></li><li><a class="js-show-comments"><i class="icon-moon-comments "></i><span>1</span></a></li><li><a href="https://www.codewars.com/kumite/new?group_id=53fb5634143fd84e940005da&amp;review_id=52bc74d4ac05d0945d000551"><span>Fork</span></a></li><li><a class="js-compare-solutions" data-tippy-content="Compare this solution to your own" data-tippy-placement="bottom"><i class="icon-moon-compare "></i>Compare with your solution</a></li><li><a href="https://www.codewars.com/kata/reviews/52bc74d4ac05d0945d000551/groups/53fb5634143fd84e940005da">Link</a></li></ul><div class="clearfix"></div><div class="clearfix"></div><ul class="comments-list is-hidden" user-votes-url="/kata/reviews/52bc74d4ac05d0945d000551/groups/53fb5634143fd84e940005da/comments/user_votes"><li class="new-comment mt-5" data-context-key="dtoyxb52ez8" data-template-selector="#_comment_new"><figure><a href="https://www.codewars.com/users/zowietao"><img title="zowietao" data-tippy-content="zowietao" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/profile-pic.f3a90aca.png"></a></figure><div class="comment-content"><div class="preedit px-1"><input class="block w-64 rounded-none rounded-md sm:text-sm dark:bg-gray-800 focus:outline-none focus:ring-cgray-300 dark:focus:ring-cgray-600 focus:border-cgray-300 dark:focus:border-cgray-600 border-gray-300 dark:border-gray-700" placeholder="Leave feedback..." type="text"></div><div class="form"><div class="markdown-editor is-compact is-vertical is-low-light"><div class="tabs"><dl class="tabs is-contained is-vertical"><dd class="is-active" data-tippy-content="Edit your message using markdown" data-tippy-placement="top"><a data-tab="markdown"><i class="icon-moon-edit "></i></a></dd><dd data-tippy-content="Preview your comment" data-tippy-placement="right"><a data-tab="preview"><i class="icon-moon-preview "></i></a></dd><dd data-tippy-content="Edit in full-screen mode" data-tippy-placement="bottom"><a class="js-expand"><i class="icon-moon-expand "></i></a></dd></dl><ul class="tabs-content"><li class="is-active" data-tab="markdown"><div class="text-editor-container"><div class="text-editor js-editor has-shadow"><div class="CodeMirror CodeMirror-wrap cm-s-codewars" translate="no"><div style="overflow: hidden; position: relative; width: 3px; height: 0px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; min-height: 1em; outline: none;"></textarea></div><div class="CodeMirror-vscrollbar" tabindex="-1" cm-not-content="true"><div style="min-width: 1px;"></div></div><div class="CodeMirror-hscrollbar" tabindex="-1" cm-not-content="true"><div style="height: 100%; min-height: 1px;"></div></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px;"><div style="position: relative;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre class="CodeMirror-line-like"><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-cursors"></div><div class="CodeMirror-code" role="presentation"></div></div></div></div></div><div style="position: absolute; height: 50px; width: 1px;"></div><div class="CodeMirror-gutters" style="left: 0px;"><div class="CodeMirror-gutter CodeMirror-foldgutter"></div></div></div></div><div class="editor-msg-container is-hidden"><div class="alert-box"></div></div></div><textarea style="display: none;"></textarea></div></li><li data-tab="preview"><div class="panel bg-ui-section is-overflow-auto"><div class="markdown prose max-w-none"><p>Your rendered <a rel="noopener" href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">github-flavored</a> markdown will appear here.</p></div></div></li></ul></div></div><div class="js-spoiler-flag mb-2"><label class="inline-flex items-center"><input class="rounded bg-gray-400 dark:bg-gray-600 border-transparent focus:border-transparent focus:bg-gray-400 text-gray-700 focus:ring-1 focus:ring-offset-2 dark:ring-offset-1 focus:ring-gray-500 dark:focus:ring-gray-700 dark:focus:ring-offset-gray-800" name="eRM" type="checkbox"><span class="ml-1" data-tippy-content="Check this if you are posting content that might give the answer to someone who hasn&#39;t solved the kata yet" data-tippy-placement="top">Mark as having spoiler content</span></label></div><ul class="btns"><li><a class="btn js-post">Post</a></li><li><a class="btn is-link js-cancel">Cancel</a></li></ul></div><div class="clearfix mb-15px"></div></div><div class="clearfix"></div></li><li class="mt-15px"><hr></li><li class="comment" id="5b515677578c6a66320000a7" data-username="snydergd" data-state="Open" data-label="no-label" data-context-key="a5limkro6l" data-template-selector="#_comment_item"><figure><a href="https://www.codewars.com/users/snydergd"><img title="snydergd" data-tippy-content="snydergd" data-tippy-placement="bottom" src="./First non-repeating character Solutions _ Codewars_files/1040083"></a></figure><div class="comment-content"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li><span class="bullet"></span><a href="https://www.codewars.com/users/snydergd">snydergd</a><span class="ml-1">(6 kyu)</span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-turbolinks="false" href="https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/solutions/javascript#5b515677578c6a66320000a7"><time-ago lang="en" datetime="2018-07-20T03:26:47.697+0000" title="2018年7月20日 GMT+8 上午11:26">4 years ago</time-ago></a></li><li class="text-ui-text-lc" style="display: none;"><span class="bullet"></span><span> edits</span></li></ul></h6><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-markdown="I like your style and that you find the solution in linear time complexity.  I just have two comments:  Why have an array for each character instead of just having a count for each?  Also, seems like a bad practice to count on object keys being returned in the order they were added."><p>I like your style and that you find the solution in linear time complexity.  I just have two comments:  Why have an array for each character instead of just having a count for each?  Also, seems like a bad practice to count on object keys being returned in the order they were added.</p></div><ul class="comment-actions bulleted-text"><li><span class="voter" data-vote-name="solution-group-comment" data-vote-ref-id="5b515677578c6a66320000a7"><span class="score">3</span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" style="display: none;"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span>Expand  Replies</span></a></li><li style="display: none;"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden"><span class="bullet"></span><a class="js-flag" data-flag="mask" data-tippy-placement="bottom" data-tippy-content="Flag this comment as a spoiler. It will be hidden from users who have not yet solved the kata."><i class="icon-moon-flag "></i><span>Spoiler</span></a></li></ul><div class="clearfix"></div><div class="nested-comments is-hidden"><ul class="comments-list"></ul></div></div></li></ul></div><div class="clearfix"></div></div></view></li><div class="p-10px js-infinite-marker" data-page="1"><h5>Loading more solutions...</h5></div></ul></div></div><div id="invalid_solutions"></div><script id="_comment_item" type="template"><li class="comment" data-bind-class="comment_class" data-bind-data-label="@label || &#39;no-label&#39;" data-bind-data-parent-id="@parent_comment_id" data-bind-data-state="@state_summary" data-bind-data-username="@user.username" data-bind-id="@id" data-bind-unless="hide_comment?"><figure><a data-bind-href="@user.profile_path" data-bind-unless="blocked_comment?"><div data-bind-replace-with="@user.avatar_tag"></div></a></figure><div class="comment-content"><include data-bind-unless="no_markdown?"><h6 class="mt-4 mb-2"><ul class="bulleted-text"><li data-bind-unless="blocked_comment?"><span class="bullet"></span><a data-bind-href="@user.profile_path" data-bind-text="@user.username"></a><span class="ml-1" data-bind-if="@user.is_mod" data-tippy-content="mod" data-tippy-placement="bottom"><svg class="inline-block" fill="none" height="15" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="15"><path d="M12 2a12 12 0 0 0 8.5 3a12 12 0 0 1 -8.5 15a12 12 0 0 1 -8.5 -15a12 12 0 0 0 8.5 -3"></path></svg></span><span class="ml-1" data-bind-if="@user.is_admin" data-tippy-content="admin" data-tippy-placement="bottom"><svg class="inline-block" fill="currentColor" height="15" stroke="currentColor" stroke-width="1" viewBox="0 0 24 24" width="15"><path d="M12 4l4 6l5 -4l-2 10h-14l-2 -10l5 4z"></path></svg></span><span class="ml-1" data-bind-html="({{@user.rank_name}})"></span></li><li><span class="bullet"></span><a class="text-ui-text-lc js-comment-id-link hover:underline" data-bind-href="@hash" data-turbolinks="false"><time-ago data-bind-datetime="@created_at_datetime" lang="en"></time-ago></a></li><li class="text-ui-text-lc" data-bind-show-if="@edit_count | any?"><span class="bullet"></span><span data-bind-if="@edit_count | one?">1 edit</span><span data-bind-text="{{@edit_count}} edits" data-bind-unless="@edit_count | one?"></span></li><li data-bind-if="@label"><div class="keyword-tag mb-0" data-bind-class="label_tag_class" data-bind-text="@label_text"></div></li></ul></h6><p class="text-ui-text-lc" data-bind-if="hide_content?"><i class="icon-moon-info is-nudged-down" data-tippy-content="Comments can be hidden by users if they feel it contains information that may spoil the experience of solving the kata for the first time. When flagged, users who have not solved the kata will not be able to see the comment." data-tippy-placement="bottom"></i><span>This comment has been hidden.</span><span class="ml-5px" data-bind-if="@masked &amp;&amp; hide_content? &amp;&amp; current_user_is_admin?">You can <a class="js-show-spoiler is-alt" data-tippy-content="Click to view the contents of this comment. It will still remained marked as a spoiler." data-tippy-placement='bottom'>view it now</a>.</span></p><p class="text-ui-text-lc" data-bind-if="blocked_comment?"><span>This comment can not be viewed.</span></p><div class="comment-markdown markdown prose max-w-none p-1 overflow-x-auto" data-bind-data-markdown="@markdown" data-bind-html="@markdown_html" data-bind-unless="blocked_comment?"></div><include data-bind-unless="guest_user? || blocked_comment?"><ul class="comment-actions bulleted-text"><li><span class="voter" data-bind-data-vote-ref-id="@id" data-vote-name="solution-group-comment"><span class="score" data-bind-text="@votes_score"></span><span class="vote" data-vote-value="1"><a class="up_vote" data-tippy-content="Up vote" data-tippy-placement="bottom"><i class="icon-moon-up "></i></a></span><span class="spacer">|</span><span class="vote" data-vote-value="-1"><a class="down_vote" data-tippy-content="Down vote" data-tippy-placement="bottom"><i class="icon-moon-down "></i></a></span></span></li><li data-bind-if="allow_reply?"><span class="bullet"></span><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li><li data-bind-if="can_edit?"><span class="bullet"></span><a class="js-edit"><i class="icon-moon-edit "></i>Edit</a></li><li data-bind-class="@show_solutions | active_class" data-bind-if="$allow_comment_solutions"><span class="bullet"></span><a class="js-show-commenter-solution"><i class="icon-moon-object "></i>View Solution</a></li><li class="is-active" data-bind-show-if="@collapsed"><span class="bullet"></span><a class="js-expand-nested"><i class="icon-moon-chevron-sign-down "></i><span data-bind-if="@comments | one?">Expand 1 Reply</span><span data-bind-text="Expand {{@comments | count}} Replies" data-bind-unless="@comments | one?"></span></a></li><li data-bind-show-if="@comments | any? &amp;&amp; !@collapsed"><span class="bullet"></span><a class="js-collapse-nested"><i class="icon-moon-chevron-sign-up "></i>Collapse</a></li><li class="is-auto-hidden" data-bind-class="@masked | active_class" data-bind-if="@markdown || !@type"><span class="bullet"></span><a class="js-flag" data-bind-data-tippy-content="masked_flag_title" data-bind-flag-masked="@masked" data-bind-flag-masked-by="@masked_by_id" data-flag="mask" data-tippy-placement="bottom"><i class="icon-moon-flag "></i><span>Spoiler</span></a></li><li class="is-auto-hidden" data-bind-if="can_remove?"><span class="bullet"></span><a class="js-remove"><i class="icon-moon-trash "></i>Remove</a></li></ul><div class="clearfix"></div><include data-bind-if="@show_solutions"><include data-bind-each="@solutions" data-template="#_compare_solution"></include></include></include></include><div class="history-item" data-bind-if="@type"><i class="icon-moon-check is-green-text"></i><span data-bind-text="{{@@label_text}} marked {{@state_text}} by "></span><a data-bind-text="{{@user.username}} "></a><time-ago class="text-ui-text-lc" data-bind-datetime="@created_at_datetime" lang="en"></time-ago></div><div class="nested-comments" data-bind-class="nested_comments_class" data-bind-unless="blocked_comment?"><ul class="comments-list"><include data-bind-each="@comments" data-template="#_comment_item"></include></ul></div><ul class="js-actions-bar comment-actions is-auto-hidden bulleted-text" data-bind-if="@comments | any? &amp;&amp; allow_reply? &amp;&amp; !@collapsed" data-bind-unless="blocked_comment?"><li><a class="js-reply"><i class="icon-moon-reply "></i>Reply</a></li></ul></div></li></script><script id="_comment_new" type="template"><li class="new-comment" data-bind-class="new_comment_class" data-bind-id="@id"><include data-bind-if="blocked_new?"><h5 class="pb-10px">Commenting is not allowed on this discussion</h5></include><include data-bind-if="guest_user?"><h5 class="pb-10px">Please <a href="https://www.codewars.com/users/sign_in" class="is-alt" data-turbolinks="false"> sign in</a>
or <a href="/" class="is-alt" data-turbolinks="false">sign up</a> to leave a comment.</h5></include><include data-bind-unless="guest_user? || blocked_new?"><figure><a data-bind-href="@user.profilePath || $profile_path"><div data-bind-replace-with="@user.avatar_tag || App.currentUser.avatar_tag"></div></a></figure><div class="comment-content"><div class="preedit px-1"><input class="block w-64 rounded-none rounded-md sm:text-sm dark:bg-gray-800 focus:outline-none focus:ring-cgray-300 dark:focus:ring-cgray-600 focus:border-cgray-300 dark:focus:border-cgray-600 border-gray-300 dark:border-gray-700" placeholder="Leave feedback..." type="text" /></div><div class="form"><div class="markdown-editor is-compact is-vertical is-low-light"><div class="tabs"><dl class="tabs is-contained is-vertical"><dd class="is-active" data-tippy-content="Edit your message using markdown" data-tippy-placement="top"><a data-tab="markdown"><i class="icon-moon-edit "></i></a></dd><dd data-tippy-content="Preview your comment" data-tippy-placement="right"><a data-tab="preview"><i class="icon-moon-preview "></i></a></dd><dd data-tippy-content="Edit in full-screen mode" data-tippy-placement="bottom"><a class="js-expand"><i class="icon-moon-expand "></i></a></dd></dl><ul class="tabs-content"><li class="is-active" data-tab="markdown"><div class="text-editor-container"><div class="text-editor js-editor has-shadow"></div><div class="editor-msg-container is-hidden"><div class="alert-box"></div></div><textarea data-bind-value="@markdown"></textarea></div></li><li data-tab="preview"><div class="panel bg-ui-section is-overflow-auto"><div class="markdown prose max-w-none"><p>Your rendered <a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank" rel="noopener">github-flavored</a> markdown will appear here.</p></div></div></li></ul></div></div><div class="js-spoiler-flag mb-2"><label class="inline-flex items-center"><input class="rounded bg-gray-400 dark:bg-gray-600 border-transparent focus:border-transparent focus:bg-gray-400 text-gray-700 focus:ring-1 focus:ring-offset-2 dark:ring-offset-1 focus:ring-gray-500 dark:focus:ring-gray-700 dark:focus:ring-offset-gray-800" data-bind-checked="@masked" name="eRM" type="checkbox" /><span class="ml-1" data-tippy-content="Check this if you are posting content that might give the answer to someone who hasn&#39;t solved the kata yet" data-tippy-placement="top">Mark as having spoiler content</span></label></div><div class="mb-10px" data-bind-if="@@ | can_resolve? &amp;&amp; @nest_level | gt:: 0 &amp;&amp; !@id"><label class="inline-flex items-center"><input class="rounded bg-gray-400 dark:bg-gray-600 border-transparent focus:border-transparent focus:bg-gray-400 text-gray-700 focus:ring-1 focus:ring-offset-2 dark:ring-offset-1 focus:ring-gray-500 dark:focus:ring-gray-700 dark:focus:ring-offset-gray-800 js-resolved" type="checkbox" /><span class="ml-1" data-bind-data-tippy-content="Mark the {{@@label_text | lower_case}} as resolved. Discussion can still continue afterwards." data-bind-text="Mark {{@@label_text | lower_case}} as resolved" data-tippy-placement="top"></span></label></div><ul class="btns" data-bind-class="labels_allowed? &amp;&amp; &#39;allows-labels&#39;"><li class="mr-15px" data-bind-if="labels_allowed?"><div class="dropdown no-scroll" style="min-width: 250px"><span><i class="icon-moon-tag "></i><span data-bind-text="label_name"></span></span><div class="placeholder">Label this discussion...</div><dl><dd class="js-default"><span>No Label</span><span class="info"><i class="icon-moon-info "></i></span><div class="info-flyout">translation missing: en.models.comment.label_info.solution_group.none</div></dd></dl></div></li><li><a class="btn js-post" data-bind-text="post_label"></a></li><li><a class="btn is-link js-cancel">Cancel</a></li></ul></div><div class="clearfix" data-bind-class="!@modal &amp;&amp; &#39;mb-15px&#39;"></div></div><div class="clearfix"></div></include></li></script><script id="_comment_new_modal" type="template"><div class="comments pr-0" data-comment-url="/kata/52bc74d4ac05d0945d00054e/comments/%7Bcomment_id%7D"><ul class="comments-list mb-0"><include data-template="#_comment_new"></include></ul></div></script><script id="_compare_solution" type="template"><div class="my-4" data-bind-class="!@completed &amp;&amp; @solution &amp;&amp; !@authorId | is_current_user? &amp;&amp; &#39;error&#39;"><label data-bind-html="@label" data-bind-if="@label"></label><pre class="p-2 overflow-x-auto" data-bind-if="@solution"><code data-bind-html="@solution | escape_html" data-language="javascript"></code></pre><p class="bg-k-40 mb-0 p-2" data-bind-unless="@solution"><i class="icon-moon-info "></i>There is no solution to show</p></div></script></div></main><div class="clearfix"></div></div><div class="clearfix"></div><footer class="p-3 text-ui-text mb-0 text-center w-auto h-50px" id="main_footer"><ul class="block list-none mx-auto mb-0 p-0 overflow-hidden space-x-5"><li class="inline-block">© 2022 Codewars</li><li class="inline-block"><a href="https://www.codewars.com/about">About</a></li><li class="inline-block"><a href="https://dev.codewars.com/" rel="noopener" target="_blank">API</a></li><li class="inline-block"><a href="https://blog.codewars.com/" rel="noopener" target="_blank">Blog</a></li><li class="inline-block"><a href="https://www.codewars.com/about/privacy">Privacy</a></li><li class="inline-block"><a href="https://www.codewars.com/about/terms-of-service">Terms</a></li><li class="inline-block"><a data-content="info@codewars.com" href="mailto:info@codewars.com" id="contactUs" rel="popover">Contact</a></li><li class="poweredby_link inline-block"><a class="hover:text-current" data-tippy-content="Supercharge your technical hiring, certification, and upskilling process with our real-world developer assessments." data-tippy-placement="top" href="https://www.qualified.io/?utm_source=codewars&amp;utm_medium=web&amp;utm_term=footer" rel="nofollow" target="_blank"><div class="flex items-baseline justify-center"><span class="pl-1 text-xs inline-block">powered by</span><img class="h-4 inline-block dark:hidden pl-1" src="./First non-repeating character Solutions _ Codewars_files/qualified-black.b052752a.svg"><img class="h-4 hidden dark:inline-block pl-1" src="./First non-repeating character Solutions _ Codewars_files/qualified-white.7cba1bde.svg"></div></a></li></ul></footer><div class="modal" id="confirm_modal" style="display: none"><div class="modal-header"><div class="close" data-dismiss="modal"><i class="icon-moon-x"></i></div><h4>Confirm</h4><div class="clearfix"></div></div><div class="clearfix"></div><div class="modal-body view"></div><div class="modal-footer"><ul class="form-actions"><li class="cancel" data-dismiss="modal"><a class="btn">Cancel</a></li><li class="alt-confirm is-hidden"><a class="btn"></a></li><li class="confirm"><a class="btn is-green"><i class="icon-general-checkmark"></i>Confirm</a></li></ul></div></div></div><div class="is-hidden" data-turbolinks-permanent="" id="template_helpers"><script id="hidden_field" type="template"><input data-bind-id="@id" data-bind-name="@name" data-bind-value="@value" type="hidden" /></script><script id="input_field" type="template"><div data-bind-class="field_class"><label data-bind-class="%required &amp;&amp; &#39;required&#39;" data-bind-for="@id" data-bind-if="%label"><abbr data-bind-if="%required" title="required">* </abbr><span data-bind-html="%label"></span></label><div data-bind-class="field_value_class"><input data-bind-id="@id" data-bind-name="@name" data-bind-type="%type || &#39;text&#39;" data-bind-value="@value | unescape_html || %defaultValue" /></div><include data-bind-each="@errors"><small data-bind-html="@"></small></include></div></script><script id="checkbox_field" type="template"><div class="boolean" data-bind-class="field_class"><div class="field_value"><div><input data-bind-name="@name" type="hidden" value="false" /><label class="checkbox"><input class="rounded bg-gray-400 dark:bg-gray-600 border-transparent focus:border-transparent focus:bg-gray-400 text-gray-700 focus:ring-1 focus:ring-offset-2 dark:ring-offset-1 focus:ring-gray-500 dark:focus:ring-gray-700 dark:focus:ring-offset-gray-800 boolean" data-bind-checked="@value" data-bind-id="@id" data-bind-name="@name" type="checkbox" value="true" /><span data-bind-html="%label || @label"></span></label></div></div></div></script><script id="markdown_field" type="template"><div class="is-full-height" data-bind-class="field_class" data-bind-if="%style | eq::&#39;full&#39;"><div class="markdown-editor is-full-height mb-0"><div class="tabs is-full-height"><dl class="tabs is-contained bg-k-40"><dd class="is-active" data-tippy-content="Edit your message using markdown" data-tippy-placement="top"><a data-bind-html="{{%label}}" data-bind-if="%label" data-tab="markdown"></a><a data-bind-unless="%label" data-tab="markdown"><i class="icon-moon-edit "></i></a></dd><dd data-tippy-content="Preview your comment" data-tippy-placement="right"><a data-tab="preview"><i class="icon-moon-preview "></i></a></dd><dd data-tippy-content="Edit in full-screen mode" data-tippy-placement="left"><a class="js-expand"><i class="icon-moon-expand "></i></a></dd></dl><div class="clearfix"></div><ul class="tabs-content is-full-height"><li class="is-full-height is-active" data-tab="markdown"><div class="text-editor-container is-full-height"><textarea class="is-hidden" data-bind-id="@id" data-bind-name="@name" data-bind-value="@value"></textarea><div class="text-editor js-editor has-shadow"></div><div class="editor-msg-container is-hidden"><div class="alert-box"></div></div></div></li><li class="is-full-height" data-tab="preview"><div class="panel bg-ui-section is-overflow-auto"><div class="markdown prose max-w-none"><p>Your rendered <a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank" rel="noopener">github-flavored</a> markdown will appear here.</p></div></div></li></ul></div></div></div><div data-bind-class="field_class" data-bind-if="%style | ne::&#39;full&#39;"><label data-bind-class="%required &amp;&amp; &#39;required&#39;" data-bind-for="@id" data-bind-if="%label"><abbr data-bind-if="%required" title="required">* </abbr><span data-bind-html="%label"></span></label><div class="markdown-editor is-tall is-low-light" data-bind-class="%markdownEditorClass"><div class="tabs"><dl class="tabs is-contained"><dd class="is-active" data-tippy-content="Edit your message using markdown" data-tippy-placement="top"><a data-tab="markdown"><i class="icon-moon-edit "></i></a></dd><dd data-tippy-content="Preview your comment" data-tippy-placement="right"><a data-tab="preview"><i class="icon-moon-preview "></i></a></dd><dd data-tippy-content="Edit in full-screen mode" data-tippy-placement="right"><a class="js-expand"><i class="icon-moon-expand "></i></a></dd></dl><ul class="tabs-content"><li class="is-full-height is-active" data-tab="markdown"><div class="text-editor-container is-full-height"><textarea class="is-hidden" data-bind-id="@id" data-bind-name="@name" data-bind-value="@value"></textarea><div class="text-editor js-editor has-shadow"></div><div class="editor-msg-container is-hidden"><div class="alert-box"></div></div></div></li><li class="is-full-height" data-tab="preview"><div class="panel bg-ui-section is-overflow-auto"><div class="markdown prose max-w-none"><p>Your rendered <a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank" rel="noopener">github-flavored</a> markdown will appear here.</p></div></div></li></ul></div></div></div></script><script id="code_editor_field" type="template"><div class="text-editor-container" data-bind-class="field_class" data-bind-id="{{@id}}_field"><label data-bind-class="%required &amp;&amp; &#39;required&#39;" data-bind-for="@id" data-bind-if="%label"><abbr data-bind-if="%required" title="required">* </abbr><span data-bind-html="%label"></span></label><textarea class="is-hidden" data-bind-id="@id" data-bind-name="@name" data-bind-value="@value"></textarea><div class="text-editor js-editor has-shadow"></div><div class="commands-container"><ul class="is-unstyled"><li class="expand" title="Maximize Editor (esc key)"><a><i class="icon-moon-expand "></i></a></li><li class="shrink is-hidden" title="Shrink Editor (esc key)"><a><i class="icon-moon-collapse "></i></a></li></ul></div><div class="editor-msg-container is-hidden"><div class="alert-box"></div></div></div></script></div><div class="p-4 shadow-lg is-hidden" data-turbolinks-permanent="" id="collection_modal" style="display: none;"><view><script type="template"><h3 class="mx-2 mt-2 mb-5 text-base font-bold">Collect: <span data-bind-html='@current.name'>kata</span></h3><div class="pl-2" data-bind-if="@loading"><p>Loading collection data...</p></div><div data-bind-unless="@loading"><div class="tabs" data-bind-unless="@adding"><dl class="tabs"><dd class="is-active"><a data-tab="personal"><i class="icon-moon-plus "></i>Add To My Collections</a></dd><dd data-bind-class="!@recent | hidden_class"><a data-tab="recent"><i class="icon-moon-collection "></i>Recently Collected In</a></dd></dl><ul class="tabs-content mb-0"><li class="is-active" data-tab="personal"><div class="collection-content" data-bind-if="enough_honor?"><div class="collections" data-bind-if="@collections.length"><ul><li data-bind-data-value="@id" data-bind-each="@collections"><div><h4><i class="icon-moon-collection "></i><span data-bind-text="@name"></span></h4><div class="info-row"><span><i class="icon-moon-compare "></i><span data-bind-text="{{@code_challenges | count | string}} kata"></span></span><a data-bind-href="/collections/{{@id}}"><i class="icon-moon-preview "></i>View</a></div></div><a class="btn is-dark is-red-text js-add-toggle" data-bind-if="added?">Remove</a><a class="btn is-dark is-green-text js-add-toggle" data-bind-unless="added?">Add</a></li></ul></div><div data-bind-unless="@collections.length"><h5>You have not created any collections yet.</h5><p>Collections are a way for you to organize kata so that you can
create your own training routines. Every collection you create is public and
automatically sharable with other warriors. After you have added a few kata to a
collection you and others can train on the kata contained within the collection.</p><p>Get started now by <a class="js-add">creating a new collection</a>.</p></div></div><div class="collection-content p-15px" data-bind-unless="enough_honor?">You must wait until you have earned at least 20 honor before you can create new collections.</div></li></ul></div><form class="new-collection px-10px" data-bind-if="@adding"><p>Set the name for your new collection. Remember, this is going to be visible by everyone
so think of something that others will understand.</p><input class="mt-4 block w-full rounded-none rounded-l-md sm:text-sm dark:bg-gray-800 focus:outline-none focus:ring-cgray-300 dark:focus:ring-cgray-600 focus:border-cgray-300 dark:focus:border-cgray-600 border-gray-300 dark:border-gray-700" placeholder="New Collection Name" type="text" /></form><div class="collection-footer border-t mt-5"><a class="btn is-green mr-15px js-create" data-bind-if="@adding">Create & Add</a><a class="btn js-done" data-bind-text="done_label"></a><a class="btn is-green float-right js-add" data-bind-unless="@adding || !enough_honor?">New Collection</a></div></div></script><div class="view"></div></view></div><script>document.addEventListener("turbolinks:load", (event) => {
  const currentUser = JSON.parse("{\"username\":\"zowietao\",\"email\":\"zowietao@qq.com\",\"role\":\"standard\",\"guest\":false,\"honor\":134,\"rank\":-6,\"current_language\":\"javascript\",\"blocked_user_ids\":[],\"blocked_by_user_ids\":[],\"jwt\":\"eyJhbGciOiJIUzI1NiJ9.eyJpZCI6IjYxZDdlYzEyNjBkNzNjMDA0MGM4ZjA2NiIsImV4cCI6MTY0NDA3NjAxNH0.iYLxfMTfy1zaV1UR9huesGOONSUPtIpFc8zkXdbe8dc\",\"experience\":\"learning\",\"subscriber\":false,\"hideAds\":false,\"id\":\"61d7ec1260d73c0040c8f066\",\"starred_code_challenge_ids\":[],\"can_resolve_comments\":false,\"avatar_tag\":\"\\u003cimg title=\\\"zowietao\\\" data-tippy-content=\\\"zowietao\\\" data-tippy-placement=\\\"bottom\\\" src=\\\"https://www.codewars.com/packs/assets/profile-pic.f3a90aca.png\\\" /\\u003e\"}");
  if (typeof gtag === "function") {
    const config = {
      page_location: event.data.url,
      page_title: event.target.title,
    };
    if (!currentUser.guest && currentUser.id) config.user_id = currentUser.id;
    gtag("config", "G-M3JYSQLS8M", config);
    if (!currentUser.guest && currentUser.experience) {
      gtag("set", "user_properties", { career_level: currentUser.experience });
    }
  }
  App.setup({
    env: "production",
    currentUser,
    data: JSON.parse("{\"routes\":{},\"controllerName\":\"code_challenges\",\"description\":\"Write a function named `first_non_repeating_letter` that takes a string input, and returns the first character that is not repeated anywhere in the string.\\n\\nFor example, if given the input `'stress'`, the function should return `'t'`, since the letter *t* only occurs once in the string, and occurs first in the string.\\n\\nAs an added challenge, upper- and lowercase letters are considered the **same character**, but the function should return the correct case for the initial letter.  For example, the input `'sTreSS'` should return `'T'`.\\n\\nIf a string contains *all repeating characters*, it should return an empty string (`\\\"\\\"`) or `None` -- see sample tests.\",\"activeLanguage\":\"javascript\",\"reviewId\":\"52bc74d4ac05d0945d000551\",\"authorId\":\"52426467add6f63696000409\",\"solution\":\"function firstNonRepeatingLetter(str) {\\n  s = str.toLowerCase()\\n  for (var i = 0; i \\u003c s.length; i++) {\\n    var n = (s.split(s[i])).length - 1;\\n    if (n == 1) return str[i]\\n  }\\n  return ''\\n}\",\"label_votes\":[],\"rank\":-5,\"assessed_rank\":null,\"vote\":null,\"completedKata\":true,\"isAuthor\":false,\"permissions\":{\"vote\":true,\"up_vote\":true,\"flag\":false,\"assess_rank\":true,\"estimate_rank\":true,\"save\":false},\"allow_comment_solutions\":true,\"avatar_tag\":\"\\u003cimg title=\\\"zowietao\\\" data-tippy-content=\\\"zowietao\\\" data-tippy-placement=\\\"bottom\\\" src=\\\"https://www.codewars.com/packs/assets/profile-pic.f3a90aca.png\\\" /\\u003e\",\"profile_path\":\"/users/zowietao\"}"),
    routes: {"user_profile":"/users/zowietao","user_stars":"/user/stars","star_code_challenge":"/users/stars/%7Bid%7D","mark_notifications_read":"/users/notifications/mark_read","unread_popup_notifications":"/users/notifications/unread_popups","collections":"/api/v1/collections","collection_code_challenge":"/api/v1/collections/%7BcollectionId%7D/code_challenges/%7Bid%7D","challenge_vote":"/kata/52bc74d4ac05d0945d00054e/vote/61ef98bc4fd88600343b5596","assess_rank":"/kata/52bc74d4ac05d0945d00054e/assess-rank/61ef98bc4fd88600343b5596","label_vote":"/kata/reviews/52bc74d4ac05d0945d000551/groups/%7BrefId%7D/label_vote/%7Blabel%7D","solution_group":"/kata/reviews/52bc74d4ac05d0945d000551/groups/%7BgroupId%7D","unlock_solutions":"/kata/52bc74d4ac05d0945d00054e/solutions/javascript?show-solutions=1","unlock_test_cases":"/kata/52bc74d4ac05d0945d00054e/solutions/javascript?show-fixtures=1","user_solution":"/kata/52bc74d4ac05d0945d00054e/javascript/solution/%7BuserId%7D"},
    pageControllerName: 'CodeChallenges.SolutionsController',
    ablyKey: "scNMAQ.WPB3NQ:wcqqMD8xujGV8lHt",
    privateChannelName: "ywF6tA",
  });
}, { once: true });</script><script>document.addEventListener("turbolinks:load", (event) => {
  if (typeof Intercom === "function" && Intercom.booted) Intercom("shutdown");
}, { once: true });</script></body><div id="edge-translate-notifier-container" class="edge-translate-notifier-center"></div></html>